Weave documentation
Weft

Fetch

Integrity-checked reconstruction, precise fallback semantics and full-payload memory use.

LocalWeftStore::fetch_payload(root, max_parallelism).await and WeftDhtStore::fetch_payload retrieve a manifest and reassemble its bytes. Structural manifest validation and chunk/root integrity checks are separate from producer signature verification; verify identity/signature as described in Manifest.

FetchRequest contains a manifest, a map from chunk index to candidate peers and a parallelism limit. The adapter trait is:

#[async_trait::async_trait]
pub trait ChunkSource: Send + Sync {
    async fn fetch_chunk(
        &self,
        peer: &weave_weft::discovery::PeerId,
        chunk: &weave_weft::chunk::ChunkDescriptor,
    ) -> weave_weft::Result<Option<Vec<u8>>>;
}

This reproduces the source trait shape; implement the library’s weave_weft::fetch::ChunkSource, rather than creating a separate incompatible trait. There is no fetch(peer, id) -> Vec<u8> method on that trait.

fetch_manifest(request, Arc<source>).await fetches chunks concurrently and restores descriptor order before concatenation. Ok(None) tries another candidate. Wrong length/hash also tries another candidate. A source Err currently propagates immediately for that chunk rather than automatically retrying every peer. The scheduler adds no general transport retry/backoff or timeout policy.

The result is a full Vec<u8>, with fetched chunks retained during assembly. Parallelism is clamped to at least one, not a total-memory bound. Final verification checks reconstructed length and Merkle root. Parity/erasure reconstruction is unsupported. InMemoryChunkSource::insert intentionally accepts unverified bytes to model dishonest peers in tests; it is not an authenticated publication API.

Source declarations