ConvergeLedger.Storage.Store (Converge Ledger v0.1.2)
View SourceMnesia-backed append-only context store.
This store is derivative, not authoritative:
- It remembers what already happened
- It never decides or coordinates convergence
- It may lose data (engine can regenerate)
- It never mutates or rewrites history
The Rust engine remains the single semantic authority.
Integrity Features
- Merkle roots: Snapshots include a Merkle root for tamper detection
- Lamport clocks: Optional causal ordering of entries
- Content hashes: Optional integrity verification per entry
Summary
Functions
Appends an entry to the context.
Appends an entry with a received Lamport timestamp.
Gets the current Lamport clock time for a context.
Gets the current sequence number for a context.
Gets entries from a context.
Loads a context from a snapshot blob.
Creates a snapshot of the entire context.
Functions
Appends an entry to the context.
Each entry is assigned:
- A sequence number (monotonically increasing per context)
- A Lamport clock timestamp (for causal ordering across contexts)
- A content hash (SHA-256 for integrity verification)
Returns {:ok, entry} with the full entry including assigned sequence number,
or {:error, reason} on failure.
Appends an entry with a received Lamport timestamp.
Use this when receiving entries from another context/node to maintain causal ordering. The local clock will be updated to max(local, received) + 1.
Returns {:ok, entry} or {:error, reason}.
Gets the current Lamport clock time for a context.
Returns {:ok, lamport_time} or {:error, reason}.
Gets the current sequence number for a context.
Returns {:ok, sequence} or {:error, reason}.
Gets entries from a context.
Options:
:key- filter by context key:after_sequence- only entries with sequence > this value:limit- maximum number of entries to return
Returns {:ok, entries, latest_sequence} or {:error, reason}.
Loads a context from a snapshot blob.
If fail_if_exists is true, returns an error if the context already has entries.
Options:
:verify_integrity- If true, verifies Merkle root before loading (default: true)
Returns {:ok, entries_restored, latest_sequence} or {:error, reason}.
Creates a snapshot of the entire context.
Returns {:ok, snapshot_blob, sequence, metadata} or {:error, reason}.