Index
Exports the PieceCID types and utility functions
Example
Section titled “Example”import { asPieceCID } from '@filoz/synapse-sdk/piece'
Modules
Section titled “Modules”Module | Description |
---|---|
<internal> | - |
Type Aliases
Section titled “Type Aliases”Type Alias | Description |
---|---|
LegacyPieceCID | LegacyPieceCID - 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. |
Functions
Section titled “Functions”Function | Description |
---|---|
asLegacyPieceCID | Convert 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. |
asPieceCID | Convert a PieceCID input (string or CID) to a validated CID This is the main function to use when accepting PieceCID inputs |
calculate | Calculate the PieceCID (Piece Commitment) for a given data blob |
createPieceCIDStream | Create a TransformStream that calculates PieceCID while streaming data through it This allows calculating PieceCID without buffering the entire data in memory |
downloadAndValidate | Download data from a Response object, validate its PieceCID, and return as Uint8Array |
downloadAndValidateFromUrl | Download data from a URL, validate its PieceCID, and return as Uint8Array |
References
Section titled “References”PieceCID
Section titled “PieceCID”Re-exports PieceCID