Skip to content

Index

Exports the PieceCID types and utility functions

import { asPieceCID } from '@filoz/synapse-sdk/piece'
ModuleDescription
<internal>-
Type AliasDescription
LegacyPieceCIDLegacyPieceCID - A constrained CID type for Legacy Piece Commitments. This is implemented as a Link type which is made concrete by a CID. A LegacyPieceCID uses the fil-commitment-unsealed codec (0xf101) and the sha2-256-trunc254-padded (0x1012) multihash function. This 32 bytes of the hash digest in a LegacyPieceCID is the same as the equivalent PieceCID, but a LegacyPieceCID does not encode the length or tree height of the original raw piece. A PieceCID can be converted to a LegacyPieceCID, but not vice versa. LegacyPieceCID is commonly known as “CommP” or simply “Piece Commitment” in Filecoin.
FunctionDescription
asLegacyPieceCIDConvert a LegacyPieceCID input (string or CID) to a validated CID This function can be used to parse a LegacyPieceCID (CommPv1) or to downgrade a PieceCID (CommPv2) to a LegacyPieceCID.
asPieceCIDConvert a PieceCID input (string or CID) to a validated CID This is the main function to use when accepting PieceCID inputs
calculateCalculate the PieceCID (Piece Commitment) for a given data blob
createPieceCIDStreamCreate a TransformStream that calculates PieceCID while streaming data through it This allows calculating PieceCID without buffering the entire data in memory
downloadAndValidateDownload data from a Response object, validate its PieceCID, and return as Uint8Array
downloadAndValidateFromUrlDownload data from a URL, validate its PieceCID, and return as Uint8Array

Re-exports PieceCID