macula_content_store (macula v13.2.1)

View Source

The content a node shares, held by the node itself (D27: a station keeps no content; the sharing node keeps it and serves it). A pure value: the owner keeps it and threads it through.

Bytes of at most one chunk (macula_manifest:default_chunk_size/0, 256 KiB) are one raw block, under the content id <<2, 16#55, SHA-384(Bytes)>>. Larger bytes are chunked by macula_manifest:create/2, and the manifest's content id is the root. A fetcher asks for a root (root/2) and then for each chunk of a manifest (chunk/2); a raw root is not a chunk, so nothing is served but what a root names. A chunk two roots share is counted, and kept until neither needs it.

Summary

Functions

The store with Bytes added, and their root content id. Opts may name the content (name), which a manifest carries; bytes already held under the same root are not added twice.

A chunk of a held manifest.

An empty store.

The store without the root MCID, and without the chunks no other root needs.

A root the store holds: a raw block's bytes, or a manifest.

The roots the store holds.

Types

store/0

-opaque store()

Functions

added(Bytes, Opts, Store)

-spec added(binary(), map(), store()) -> {macula:mcid(), store()}.

The store with Bytes added, and their root content id. Opts may name the content (name), which a manifest carries; bytes already held under the same root are not added twice.

chunk(MCID, Store)

-spec chunk(macula:mcid(), store()) -> {ok, binary()} | not_found.

A chunk of a held manifest.

new()

-spec new() -> store().

An empty store.

removed(MCID, Store)

-spec removed(macula:mcid(), store()) -> store().

The store without the root MCID, and without the chunks no other root needs.

root(MCID, Store)

-spec root(macula:mcid(), store()) ->
              {block, binary()} | {manifest, macula_manifest:manifest()} | not_found.

A root the store holds: a raw block's bytes, or a manifest.

roots(Store)

-spec roots(store()) -> [macula:mcid()].

The roots the store holds.