ConvergeLedger.Entry (Converge Ledger v0.1.2)
View SourceRepresents a single append-only entry in a context.
Entries are immutable once created. The only way to "change" data is to append a new entry that supersedes it.
Integrity Fields
lamport_clock: Optional Lamport timestamp for causal ordering. When set, provides happened-before relationships across entries.content_hash: Optional SHA-256 hash of the entry content. Computed automatically when integrity tracking is enabled.
Summary
Functions
Converts a Mnesia record tuple to an Entry struct.
Returns true if the entry has integrity fields set.
Creates a new entry with an auto-generated ID and timestamp.
Converts an entry to a Mnesia record tuple.
Verifies the integrity of an entry by checking its content hash.
Types
@type t() :: %ConvergeLedger.Entry{ appended_at_ns: non_neg_integer(), content_hash: binary() | nil, context_id: String.t(), id: String.t(), key: String.t(), lamport_clock: non_neg_integer() | nil, metadata: map(), payload: binary(), sequence: non_neg_integer() }
Functions
Converts a Mnesia record tuple to an Entry struct.
Handles both old format (8 fields) and new format (10 fields with integrity).
Returns true if the entry has integrity fields set.
Creates a new entry with an auto-generated ID and timestamp.
Options
:lamport_clock- Lamport timestamp for causal ordering:content_hash- SHA-256 hash for integrity verification
Converts an entry to a Mnesia record tuple.
The record format includes integrity fields (lamport_clock, content_hash).
Verifies the integrity of an entry by checking its content hash.
Returns:
{:ok, :verified}if the content hash matches{:ok, :no_hash}if the entry has no content hash (legacy entry){:error, :hash_mismatch}if the content hash doesn't match (tampered)