Skip to content

findPiece

findPiece(options): Promise<PieceCID>

Defined in: packages/synapse-core/src/sp/find-piece.ts:65

Find a piece on the PDP API.

GET /pdp/piece?pieceCid={pieceCid}

Transient failures (5xx, 429, network errors) are retried. HTTP errors and timeouts are thrown as FindPieceError with the original error as cause; notFound tells a missing piece apart from other failures.

Parameter Type Description
options OptionsType findPiece.OptionsType

Promise<PieceCID>

Piece CID findPiece.OutputType

import * as SP from '@filoz/synapse-core/sp'
import * as Piece from '@filoz/synapse-core/piece'

// wait for an uploaded piece to be parked
const pieceCid = await SP.findPiece({
  serviceURL: 'https://pdp.example.com',
  pieceCid: Piece.from('bafkzcib...'),
  poll: true,
})

Errors findPiece.ErrorType