Skip to content

createPieceBatcher

createPieceBatcher(client, options): PieceBatcher

Defined in: packages/synapse-core/src/sp/create-piece-batcher.ts:151

Create a stateful piece batcher that parks/pulls immediately and coalesces addPieces.

upload and pull run per-piece I/O right away (upload uses the streaming CommP-last protocol for bytes and streams). The tumbling window only batches the on-chain addPieces (or createDataSetAndAddPieces) call. Pull authorization uses signAddPieces for that one piece; flush signs a new extraData for the whole window.

ParameterTypeDescription
clientClient<Transport, Chain, Account>Wallet client used to sign and submit.
optionsOptionsTypecreatePieceBatcher.OptionsType

PieceBatcher

Batcher createPieceBatcher.ReturnType

import { createPieceBatcher } from '@filoz/synapse-core/sp'
const batcher = createPieceBatcher(client, { dataSet })
await Promise.all([
batcher.upload({ data: fileA }),
batcher.pull({ pieceCid, sourceUrl }),
])
await batcher.close()