Skip to content

waitForFlushReceipt

waitForFlushReceipt(client, result, options?): Promise<OutputType>

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

Wait for a flushed batch to land on chain and get its piece IDs.

Follows replace-by-fee replacements with waitForAddPieces. A flush that created the data set already waited for its transaction, so its outcome is returned without waiting again.

Parameter Type Description
client Client<Transport, Chain> The client to wait with.
result FlushResult The flush result, from PieceBatcher.flush or any piece’s result.
options OptionsType waitForFlushReceipt.OptionsType

Promise<OutputType>

The outcome waitForFlushReceipt.OutputType. pieceIds[batchIndex] is a piece’s ID.

Errors waitForFlushReceipt.ErrorType

import { createPieceBatcher, waitForFlushReceipt } from '@filoz/synapse-core/sp'

const batcher = createPieceBatcher(client, { dataSet })
const result = await batcher.upload({ data: file })
const { pieceIds } = await waitForFlushReceipt(client, result)
const pieceId = pieceIds[result.batchIndex]