Skip to main content

Module range_pull

Module range_pull 

Source
Expand description

Bao verified-range helpers — re-exported from the iroh-blobs-free decdn_bao_range leaf crate (#578) so decdn-client can share the exact same alignment / encoded-size / verify logic without linking iroh-blobs. The serve (engine::export_bao_range), origin range encode (engine::origin_range_wire), and client-receive paths therefore all agree by construction. See ADR 038 §Wire format.

The block size IROH_BLOCK_SIZE is declared in the leaf crate from the bao-tree primitive; the lock-step test below asserts it stays byte-identical to iroh_blobs::store::IROH_BLOCK_SIZE, so an iroh-blobs bump that changed the canonical block size — a protocol-contract change under ADR 038 — fails here.

Structs§

AlignedRange
The chunk-group-aligned byte span a node must fetch from origin to serve a requested [byte_offset, byte_offset + byte_len), plus the chunk ranges to import. A bao proof covers whole 16 KiB groups, so the fetch widens to the enclosing group boundaries (the extra bytes are paid origin egress but never re-served as client bytes — the request is still scoped, not whole-blob). Fields are private and the only constructor is align_range, so holding an AlignedRange guarantees its invariants: fetch_start <= fetch_end, both group-aligned (or fetch_end == blob_size for the final partial group), and chunk_ranges exactly covers [fetch_start, fetch_end).

Enums§

RangeVerifyError
Errors from preparing a verified origin range pull.

Constants§

IROH_BLOCK_SIZE
iroh-blobs’ canonical on-disk block size (16 KiB chunk groups, from_chunk_log(4)). Declared from the bao-tree primitive rather than re-exported from iroh-blobs, because this leaf crate must stay iroh-blobs-free (#578) so the CLI’s pull path can link it. The value is identical by construction to iroh_blobs::store::IROH_BLOCK_SIZE (which is also BlockSize::from_chunk_log(4)); decdn-cache carries a lock-step test asserting the two stay equal, so a divergence across an iroh-blobs bump — which ADR 038 treats as a protocol-contract change — fails the build there.

Functions§

align_range
Compute the chunk-group-aligned fetch span for a [byte_offset, +byte_len) request against a blob_size-byte blob. byte_len == 0 means “to end”.
align_range_clamped
align_range, but an end past the blob clamps to the blob’s end instead of being refused: a claimed size is a hint, and the planner’s bound can overshoot it. Only byte_offset >= blob_size (for a non-empty blob) is refused, with RangeVerifyError::RangeOutOfBounds: a start past the end has no chunk group to anchor, clamped or not. (0, 0) means the whole blob, and the empty blob is addressable only as (0, 0), exactly as in align_range.
bao_encoded_size
Exact byte length of the header-less bao interleaved encoding a serving node emits for chunk_ranges of a total_bytes-byte blob — the sum of every proof node (64 bytes each) and data leaf (≤ chunk-group bytes) in response (pre-order) order (ADR 038 §Wire format).
encode_verified_range
Verify range_data (covering aligned.fetch_start..aligned.fetch_end) and the supplied pre-order outboard against the wanted root root, returning the bao interleaved encoding for aligned.chunk_ranges — ready for Blobs::import_bao_bytes(root, aligned.chunk_ranges, _).