macula_content (macula v0.20.3)
View SourcePublic API facade for Macula content-addressed storage system.
Provides a simple, high-level interface for content operations: - Publishing: Store content and announce to mesh - Fetching: Download content from mesh peers - Verification: Ensure content integrity via Merkle proofs
Quick Start
%% Publish content (returns manifest MCID)
{ok, MCID} = macula_content:publish("/path/to/release.tar.gz").
%% Fetch content by MCID
{ok, FilePath} = macula_content:fetch(MCID, #{output_dir => "/tmp"}).
%% Check if content is available locally
true = macula_content:is_local(MCID).MCID Format
MCIDs are 34-byte content identifiers: - Version (1 byte): Protocol version - Codec (1 byte): Content type (0x55 = raw, 0x56 = manifest) - Hash (32 bytes): BLAKE3 or SHA256 content hash
Summary
Functions
Create manifest from binary data.
Create manifest from binary data with options. Options: - name: Content name (default: "unnamed") - chunk_size: Chunk size in bytes (default: 262144 / 256KB) - hash_algorithm: blake3 | sha256 (default: blake3)
Fetch content by MCID. If available locally, returns immediately. Otherwise, discovers providers and downloads.
Fetch content with options. Options: - verify: Verify Merkle root after download (default: true) - timeout: Download timeout in ms (default: 300000 / 5 min)
Get list of chunks from manifest.
Check if content is available locally.
Create MCID from binary data using default algorithm (BLAKE3).
Create MCID from binary data with options. Options: - hash_algorithm: blake3 | sha256 (default: blake3)
Parse MCID from string representation.
Convert MCID to human-readable string. Format: mcid1-{codec}-{algorithm}-{hash_hex}
Get list of chunks not yet stored locally.
Get content system status.
Store binary content locally. Creates manifest, chunks data, stores blocks.
Store binary content with options.
Verify data against manifest. Returns true if data matches manifest's root hash.
Types
Functions
Create manifest from binary data.
Create manifest from binary data with options. Options: - name: Content name (default: "unnamed") - chunk_size: Chunk size in bytes (default: 262144 / 256KB) - hash_algorithm: blake3 | sha256 (default: blake3)
Fetch content by MCID. If available locally, returns immediately. Otherwise, discovers providers and downloads.
Fetch content with options. Options: - verify: Verify Merkle root after download (default: true) - timeout: Download timeout in ms (default: 300000 / 5 min)
-spec get_chunks(manifest()) -> [chunk_info()].
Get list of chunks from manifest.
Check if content is available locally.
Create MCID from binary data using default algorithm (BLAKE3).
Create MCID from binary data with options. Options: - hash_algorithm: blake3 | sha256 (default: blake3)
Parse MCID from string representation.
Convert MCID to human-readable string. Format: mcid1-{codec}-{algorithm}-{hash_hex}
-spec missing_chunks(manifest()) -> [chunk_info()].
Get list of chunks not yet stored locally.
-spec status() -> map().
Get content system status.
Store binary content locally. Creates manifest, chunks data, stores blocks.
Store binary content with options.
Verify data against manifest. Returns true if data matches manifest's root hash.