IPFS
IPFS distributes serialized ALX Blocks through content-addressed retrieval.
Applications receive a CID, retrieve the associated bytes, and validate the resulting Block locally. ALX blockHash identifies canonicalized Block content and declared parents. An IPFS CID identifies raw file bytes. Applications retain both identifiers when distributing Blocks through IPFS.
Two Identifiers
Applications maintain the mapping between blockHash and CID.
| Property | ALX blockHash | IPFS CID |
|---|---|---|
| Role | Identifies an ALX Block | Identifies retrievable bytes |
| Hash function | Keccak-256 | Multihash selected by the CID |
| Input | Canonicalized content and parentHashes | Raw file bytes |
| Verified by | A conforming ALX implementation | IPFS content addressing |
Application Integration
Applications select and operate the IPFS client, gateway, pinning policy, and identifier mapping. Treat retrieval transport and gateway responses as untrusted input until local validation succeeds. After retrieval:
- Parse the retrieved bytes with
parseStrictJsonBytes()from@alx-protocol/sdkto reject invalid UTF-8 and duplicate JSON members. - Call
validateBlock()and requireokto betrue. - Compare
blockHash.recomputedwith the expectedblockHash. - Accept the Block only after both checks succeed.
When to Use IPFS
Use IPFS when an application needs CID-based distribution across infrastructure boundaries. Use application storage when the application controls persistence and retrieval directly. The selected storage layer preserves ALX Block identity and declared lineage.
Responsibilities Around IPFS
- Availability: Configure nodes or pinning services for the required retention period.
- Lineage: Read declared parent relationships from
parentHashesinside each Block. - Block identity: Verify
blockHashwith ALX protocol rules after retrieving the bytes. - Identifier mapping: Retain the CID-to-
blockHashassociation in the application.