macula_content_store (macula v0.20.5)
View SourceContent store module for Macula content-addressed storage.
Provides local storage and retrieval of content blocks and manifests. Uses file-based storage with directory sharding (first 2 hex chars of hash) for efficient organization.
Storage Layout
{base_dir}/
├── blocks/
│ ├── 5d/
│ │ └── 5d41402abc4b2a76b9719d911017c592.blk
│ └── ...
├── manifests/
│ ├── 7f/
│ │ └── 7f83b1657ff1fc53b92dc18148a1d65d.man
│ └── ...
└── index.detsExample Usage
%% Store a block
Data = <<"content">>,
MCID = compute_mcid(Data),
ok = macula_content_store:put_block(MCID, Data),
%% Retrieve with verification
{ok, Data} = macula_content_store:get_block(MCID).
Summary
Functions
Get the file path for a block MCID. Uses first 2 hex chars of hash for directory sharding.
Delete a block from the store.
Delete a manifest from the store.
Garbage collect orphaned blocks not referenced by any manifest.
Retrieve a block by its MCID. Verifies the retrieved data matches the MCID hash.
Retrieve a manifest by its MCID.
Check if a block exists in the store.
List all manifest MCIDs.
Get the file path for a manifest MCID.
Store a block by its MCID. Verifies the data matches the MCID hash before storing.
Store a manifest.
Start the content store server.
Get storage statistics.
Stop the content store server.
Verify integrity of all stored blocks.
Functions
Get the file path for a block MCID. Uses first 2 hex chars of hash for directory sharding.
-spec delete_block(binary()) -> ok.
Delete a block from the store.
-spec delete_manifest(binary()) -> ok.
Delete a manifest from the store.
-spec gc() -> {ok, #{removed := non_neg_integer()}}.
Garbage collect orphaned blocks not referenced by any manifest.
Retrieve a block by its MCID. Verifies the retrieved data matches the MCID hash.
Retrieve a manifest by its MCID.
Check if a block exists in the store.
-spec list_manifests() -> [binary()].
List all manifest MCIDs.
Get the file path for a manifest MCID.
Store a block by its MCID. Verifies the data matches the MCID hash before storing.
Store a manifest.
Start the content store server.
-spec stats() -> map().
Get storage statistics.
-spec stop() -> ok.
Stop the content store server.
-spec verify_integrity() -> {ok, non_neg_integer()} | {error, {corrupted, [binary()]}}.
Verify integrity of all stored blocks.