Skip to content

getPdpDataSet

getPdpDataSet(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/warm-storage/get-pdp-data-set.ts:66

Get a PDP data set by ID.

Existing data sets without an active PDP product have provider: null.

The result reports piece presence from a non-zero getDataSetLeafCount read, which is an O(1) storage lookup, rather than scanning piece IDs. Exact active-piece counts are omitted because the contract’s count getter performs a linear scan and can fail for large data sets. To derive an exact count explicitly, traverse getActivePiecesByCursor with paginate and count the yielded pieces.

Parameter Type Description
client Client<Transport, Chain> The client to use to get the PDP data set.
options OptionsType getPdpDataSet.OptionsType

Promise<OutputType>

PDP data set or undefined if the data set does not exist getPdpDataSet.OutputType

Errors getPdpDataSet.ErrorType

import { getPdpDataSet } from '@filoz/synapse-core/warm-storage'
import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'

const client = createPublicClient({
  chain: calibration,
  transport: http(),
})

const dataSet = await getPdpDataSet(client, {
  dataSetId: 1n,
})

if (dataSet) {
  console.log(dataSet.dataSetId)
} else {
  console.log('Data set does not exist')
}