Skip to content

getSizeFromPieceCID

function getSizeFromPieceCID(pieceCidInput): number;

Defined in: packages/synapse-sdk/src/piece/piece.ts:220

Extract the raw (unpadded) size from a PieceCIDv2

PieceCIDv2 encodes the original data size in its multihash digest through the tree height and padding values. This function decodes those values to calculate the original raw data size.

ParameterTypeDescription
pieceCidInput| string | PieceLink | CID<unknown, number, number, Version>PieceCID as either a CID object or string

number

The raw size in bytes

If the input is not a valid PieceCIDv2