getActivePieceCount
getActivePieceCount(
client,options):Promise<bigint>
Defined in: packages/synapse-core/src/pdp-verifier/get-active-piece-count.ts:49
Get the active piece count for a data set (non-zero leaf count)
This contract method scans the complete historical piece-ID range and can run out of gas for large data sets. Prefer explicitly traversing getActivePiecesByCursor when reliability for large sets is required.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
client |
Client<Transport, Chain> |
The client to use to get the active piece count. |
options |
OptionsType |
getActivePieceCount.OptionsType |
Returns
Section titled “Returns”Promise<bigint>
The active piece count for the data set getActivePieceCount.OutputType
Example
Section titled “Example”import { getActivePieceCount } from '@filoz/synapse-core/pdp-verifier'
import { calibration } from '@filoz/synapse-core/chains'
import { createPublicClient, http } from 'viem'
const client = createPublicClient({
chain: calibration,
transport: http(),
})
const activePieceCount = await getActivePieceCount(client, { dataSetId: 1n })