Expand description
An authenticated, indexed, append-only log over rfc9162 and
rfc9162_tiles: the contract, the store that keeps it, and a sidecar
over a project tree.
rfc9162 is the tree; rfc9162-tiles stores it with key sidecars that
the checkpoint does not sign, finds a key by filtered scan, and detects a
torn tail without proving the recovery. This crate adds, as a contract
(AuthenticatedLog) and a store (Store) behind it:
- every index structure is itself logged, so the checkpoint that signs
the entries signs the index (
RunManifest::manifest_index); - a lookup answers with the entry and with the run that located it, each
carrying an inclusion path (
Located); - keys are sorted into runs with a range, so a prefix or range query is
a seek through
RunManifest::key_loandRunManifest::key_hi; - compaction writes a new run and logs it; the runs it replaces stay in
the log and stay provable (
Compaction); - recovery replays the tail past the last signed checkpoint and proves the
result consistent with it (
Recovery).
Sidecar sits beside a project tree the way .git does: every change
to a path is an entry whose bytes are a content-addressed blob in the
same store, a snapshot is a signed checkpoint, and over a
rfc9162_tiles::PackStore the whole history is one file.
use std::sync::Arc;
use rfc9162_log::{AuthenticatedLog, Store};
use rfc9162_tiles::MemoryStore;
let mut log = Store::open(MemoryStore::new(), Arc::new(|_| Vec::new()))?;
let index = log.append(b"alpha")?;
log.seal()?;
let found = log.find(&rfc9162_tiles::index::identity(b"alpha"))?;
assert_eq!(found[0].entry.index, index);
let bytes = log.index()?.reader().get(index)?.unwrap();
assert!(rfc9162::verify_inclusion(
&rfc9162::leaf_hash(&bytes),
index as usize,
found[0].entry.tree_size as usize,
&found[0].entry.path,
&rfc9162::hex(&log.root()),
));Re-exports§
pub use sidecar::Change;pub use sidecar::Found;pub use sidecar::Op;pub use sidecar::Sidecar;pub use sidecar::Synced;pub use store::Keys;pub use store::Store;
Modules§
- sidecar
- A sidecar log beside a project tree: every change to a path is an entry, the bytes it wrote are a content-addressed blob in the same store, and a snapshot is a signed checkpoint.
- store
- The store behind
AuthenticatedLog: sorted runs overrfc9162_tiles, each run’s manifest appended to a log so a signed checkpoint covers the index as well as the entries.
Structs§
- Compaction
- One compaction: the runs it replaced and the run it wrote, each a logged manifest. The replaced runs remain in the log; a reader at an older checkpoint still proves through them.
- Inclusion
- An inclusion path for one entry at one tree size, as
rfc9162checks it: the sibling hashes from the leaf to the root. - Located
- What a lookup returns: the entry the key names and the run that located it, both with inclusion paths against the same tree size, so the reader proves the answer and the index that gave it with one root.
- Recovery
- What recovery proved after a crash: the checkpoint it started from, the
entries replayed beyond it, and that the recovered tree is consistent
with the checkpoint by
rfc9162::verify_consistency. - RunManifest
- A sealed, sorted run of lookup keys over a contiguous range of entries, recorded in the log as an entry of its own so the checkpoint signs it.
Enums§
- Error
- What can go wrong between a caller and the store.
Traits§
- Authenticated
Log - The operations the log offers. Each returns the crate’s
Erroron a store that cannot answer; a reader that distrusts the store checks the paths these types carry against a checkpoint it trusts.