Skip to content

Index

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.
PieceCIDPieceCID - A constrained CID type for Piece Commitments. This is implemented as a Link type which is made concrete by a CID. A PieceCID uses the raw codec (0x55) and the fr32-sha256-trunc254-padbintree multihash function (0x1011) which encodes the base content length (as padding) of the original piece, and the height of the merkle tree used to hash it.
VariableDescription
MAX_UPLOAD_SIZEMaximum upload size currently supported by PDP servers.
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
calculateFromIterableCalculate PieceCID from an async iterable of Uint8Array chunks.
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
getSizeExtract the raw (unpadded) size from a PieceCIDv2
getSizeFromPieceCIDExtract the raw (unpadded) size from a PieceCIDv2
hexToPieceCIDConvert a hex representation of a PieceCID to a PieceCID object
isPieceCIDCheck if a CID is a valid PieceCID
parse-
uint8ArrayToAsyncIterableConvert Uint8Array to async iterable with optimal chunk size.