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§
- Aligned
Range - 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 isalign_range, so holding anAlignedRangeguarantees its invariants:fetch_start <= fetch_end, both group-aligned (orfetch_end == blob_sizefor the final partial group), andchunk_rangesexactly covers[fetch_start, fetch_end).
Enums§
- Range
Verify Error - 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 thebao-treeprimitive rather than re-exported fromiroh-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 toiroh_blobs::store::IROH_BLOCK_SIZE(which is alsoBlockSize::from_chunk_log(4));decdn-cachecarries 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 ablob_size-byte blob.byte_len == 0means “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. Onlybyte_offset >= blob_size(for a non-empty blob) is refused, withRangeVerifyError::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 inalign_range.- bao_
encoded_ size - Exact byte length of the header-less bao interleaved encoding a serving
node emits for
chunk_rangesof atotal_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(coveringaligned.fetch_start..aligned.fetch_end) and the supplied pre-orderoutboardagainst the wanted rootroot, returning the bao interleaved encoding foraligned.chunk_ranges— ready forBlobs::import_bao_bytes(root, aligned.chunk_ranges, _).