Expand description
Fixed-size chunking, Merkle-root computation, and manifest
construction for content larger than one storage block. Ported from
macula’s own macula_manifest (SDK) — see
plans/PLAN_WIRE_PROTOCOL.md §12.2.
Mirrors the reference byte-for-byte: same MCID format, same default
chunk size (256 KiB), same Merkle fold (including the odd-leaf-count
rule — pair the last hash with itself), same canonical-CBOR MCID
derivation. Verified against real macula_manifest:create/2 /
chunk_mcid/3 / verify/2 output (even and odd chunk counts, to
exercise both branches of the Merkle fold) — see this module’s tests.
Two different wire representations of name, both verified
separately, not confused with each other: compute_mcid’s
canonical hash input wraps name as CBOR text (a deliberate,
narrow special case in the reference, just for that hash
computation), while to_wire — the actual manifest map as sent in
a _content.put_manifest CALL payload — encodes name as a raw
byte string, matching its binary() type. Confirmed directly by
encoding a real manifest through the general deterministic-CBOR
codec and inspecting the bytes, not inferred from the type spec
alone — see the CALL/PUBLISH procedure/topic lesson in
src/frame.rs for why that inference alone wasn’t trusted here.
Structs§
Enums§
Constants§
- DEFAULT_
CHUNK_ SIZE - 256 KiB — matches
macula_manifest:default_chunk_size/0.
Functions§
- block_
mcid - The MCID a whole blob is stored/fetched under when it’s small enough
to be a single block (no manifest at all). Matches
macula_content_transfer:put_single_block/3exactly: always BLAKE3, regardless of any algorithm preference — single-block content has no algorithm choice, only chunked/manifest content does. - chunk_
mcid - The MCID a chunk at
indexis stored/fetched under — the station derives this same value independently when serving the chunk, so both sides agree on its address without exchanging it. - create
- Split
datainto fixed-size chunks and build its manifest. Returns the manifest and the chunk bytes in order (index 0 first) — a caller uploads each chunk (_content.put_block) then the manifest itself (_content.put_manifest), per §12.2. - from_
wire - Parse a manifest as received from a
_content.get_manifestRESULT. - mcid_
is_ chunked - Whether
mcidaddresses a manifest (chunked content) rather than a single raw block — determined from its own codec byte, no network round trip needed. Matchesmacula_content_transfer:is_chunked/2’s get-side check. - to_wire
- Encode
manifestas it’s actually sent in a_content.put_manifestCALL payload —nameas bytes (its realbinary()type), NOT the text-wrapped formcompute_mciduses internally. See this module’s doc comment. - verify
- Verify reassembled
dataagainstmanifest: size, then a fresh Merkle root overdatare-chunked the same way.
Type Aliases§
- Mcid
<<Version:8, Codec:8, Hash:32/binary>>— 34 bytes.