Skip to main content

ChunkSource

ChunkSource defines an interface to retrieve file chunks from any source.
This is used by ReconstructionService to read chunks before reconstruction.


Methods

MethodReturnsDescription
getChunk(hash)Promise<Buffer>Returns a single chunk by its hash.
getChunks?(hashes, options?)Promise<Map<string, Buffer>>Optional method to fetch multiple chunks concurrently.
streamChunks?(hashes, options?)AsyncGenerator<{ hash: string; data: Readable }>Optional method to stream chunks, possibly preserving order.

Method details

getChunk(hash)

Returns a single chunk by its hash from the source.

Parameters:

NameTypeDescription
hashstringHash identifier of the chunk

Returns: Promise<Buffer>


getChunks?(hashes, options?)

Fetch multiple chunks concurrently.

Parameters:

NameTypeDescription
hashesstring[]List of all hashes to fetch
options.concurrency?numberOptional concurrency limit for downloading chunks

Returns: Promise<Map<string, Buffer>>


streamChunks?(hashes, options?)

Stream given chunks from the source.

Parameters:

NameTypeDescription
hashesstring[]List of all hashes to fetch
options.concurrency?numberOptional concurrency limit for downloading chunks
options.preserveOrder?booleanOptional boolean to emit chunks in order

Returns: AsyncGenerator<{ hash: string; data: Readable }>


Implementations

Below are the main implementations of ChunkSource. Each is fully usable by end users.