getActivePiecesByCursor
getActivePiecesByCursor(
client,options):Promise<OutputType>
Defined in: packages/synapse-core/src/pdp-verifier/get-active-pieces-by-cursor.ts:69
Get one bounded page of active pieces using efficient piece-ID cursors.
The cursor is a piece ID, but callers should still treat nextCursor as
opaque and pass it back unchanged. Use paginate to traverse every
page, including sparse piece-ID ranges.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client |
Client<Transport, Chain> |
Client used to read the PDP Verifier. |
options |
OptionsType |
getActivePiecesByCursor.OptionsType |
Returns
Section titled “Returns”A page of active pieces getActivePiecesByCursor.OutputType
Throws
Section titled “Throws”Errors getActivePiecesByCursor.ErrorType
Examples
Section titled “Examples”Read the first page
import { getActivePiecesByCursor } from '@filoz/synapse-core/pdp-verifier'
const page = await getActivePiecesByCursor(client, { dataSetId: 1n })
console.log(page.items, page.nextCursor)Iterate over every page
import { paginate } from '@filoz/synapse-core'
import { getActivePiecesByCursor } from '@filoz/synapse-core/pdp-verifier'
for await (const piece of paginate(({ cursor }) =>
getActivePiecesByCursor(client, { dataSetId: 1n, cursor })
)) {
console.log(piece.id, piece.cid)
}