Skip to content

hasPiece

hasPiece(options): Promise<boolean>

Defined in: packages/synapse-core/src/sp/has-piece.ts:34

Check whether a provider has a piece.

GET /pdp/piece?pieceCid={pieceCid}

A single findPiece lookup, without polling, that returns false instead of throwing when the provider answers that it does not have the piece (404) or is still processing it (202). Other failures, such as a 5xx response or a timeout, still throw, as does an abort.

Parameter Type Description
options OptionsType hasPiece.OptionsType

Promise<boolean>

Whether the provider has the piece hasPiece.OutputType

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

const found = await SP.hasPiece({
  serviceURL: 'https://pdp.example.com',
  pieceCid: Piece.from('bafkzcib...'),
})

Errors hasPiece.ErrorType