Skip to main content

encode_sparse_cache

Function encode_sparse_cache 

Source
pub fn encode_sparse_cache(
    manifest: &SparseManifest,
    proof: &SparseProof,
) -> Vec<u8> 
Expand description

Encode the on-disk cache payload for a verified sparse delivery.

Layout:

0   4   magic        = SPARSE_CACHE_MAGIC ("MSPC")
4   1   version      = SPARSE_CACHE_VERSION
5   32  bitmap_root
37  32  filter_hash
69  8   leaf_count   (u64 LE)
77  4   bitmap_len   (u32 LE)
81  N   bitmap_bytes

The tree_hash is not stored in the file body — it is the filename. Re-verifying a cached bitmap means recomputing the bitmap root from the bytes and comparing to bitmap_root here.