Skip to content

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.

ParameterTypeDescription
clientClient<Transport, Chain>Client used to read the PDP Verifier.
optionsOptionsTypegetActivePiecesByCursor.OptionsType

Promise<OutputType>

A page of active pieces getActivePiecesByCursor.OutputType

Errors getActivePiecesByCursor.ErrorType

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)
}