createPieceBatcher
createPieceBatcher(
client,options):PieceBatcher
Defined in: packages/synapse-core/src/sp/create-piece-batcher.ts:138
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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client | Client<Transport, Chain, Account> | Wallet client used to sign and submit. |
options | OptionsType | createPieceBatcher.OptionsType |
Returns
Section titled “Returns”Batcher createPieceBatcher.ReturnType
Example
Section titled “Example”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()