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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
OptionsType |
hasPiece.OptionsType |
Returns
Section titled “Returns”Promise<boolean>
Whether the provider has the piece hasPiece.OutputType
Example
Section titled “Example”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...'),
})Throws
Section titled “Throws”Errors hasPiece.ErrorType