pub struct Shard {
pub file_hash: String,
pub file_len: u64,
pub xorb_hashes: Vec<String>,
pub mdb_bytes: Vec<u8>,
}Expand description
The reconstruction manifest for a single file: the .mdb bytes plus the
derived metadata the protocol response carries (file hash, length, xorb
hashes).
Fields§
§file_hash: StringHex-encoded file merkle hash this shard reconstructs.
file_len: u64Total file length in bytes (sum of all segment byte lengths).
xorb_hashes: Vec<String>Hex-encoded xorb hashes the file was split across, in order.
mdb_bytes: Vec<u8>The raw .mdb shard bytes (the XET wire format).
Implementations§
Source§impl Shard
impl Shard
Sourcepub fn from_chunks(chunks: &[Chunk]) -> (Shard, Vec<(MerkleHash, Vec<u8>)>)
pub fn from_chunks(chunks: &[Chunk]) -> (Shard, Vec<(MerkleHash, Vec<u8>)>)
Build a shard from the file’s chunk list, grouping chunks into xorbs
that respect the XET MAX_XORB_BYTES (64 MiB) and MAX_XORB_CHUNKS
(8192) limits. Returns the shard plus, for each xorb in order, the
xorb hash and the concatenated xorb bytes.
Chunk → xorb aggregation, xorb hashing (merklehash::xorb_hash), and
file hashing (merklehash::file_hash) all match xet-core’s
RawXorbData::from_chunks, so the hashes embedded in the produced
shard are identical to an upstream client’s.
Sourcepub fn from_chunks_with_cap(
chunks: &[Chunk],
xorb_byte_cap: usize,
) -> (Shard, Vec<(MerkleHash, Vec<u8>)>)
pub fn from_chunks_with_cap( chunks: &[Chunk], xorb_byte_cap: usize, ) -> (Shard, Vec<(MerkleHash, Vec<u8>)>)
Like [from_chunks], but with a custom per-xorb byte cap. Used by tests
to force multi-xorb aggregation without allocating 64 MiB. The chunk
count cap (MAX_XORB_CHUNKS = 8192) still applies.