pub struct Ledger {Show 16 fields
pub last_seq: u64,
pub next_txn: u64,
pub live: IdMap<LiveTxn>,
pub terminal: BTreeMap<TxnId, TerminalTxn>,
pub overrides: Vec<Override>,
pub incidents: BTreeMap<IncidentId, Incident>,
pub tokens_used: Vec<([u8; 16], Timestamp)>,
pub known_good: Option<GenerationId>,
pub live_tested: Option<GenerationId>,
pub accepted_baseline: Option<GenerationId>,
pub security_floor: Option<GenerationId>,
pub external: Option<(u64, Hash)>,
pub interlock: IdMap<InterlockEntry>,
pub last_reconciliation: Option<Reconciliation>,
pub agents: Vec<(String, [u8; 16], u32)>,
pub hold_events: Vec<(UnitId, bool)>,
}Fields§
§last_seq: u64§next_txn: u64§live: IdMap<LiveTxn>§terminal: BTreeMap<TxnId, TerminalTxn>§overrides: Vec<Override>§incidents: BTreeMap<IncidentId, Incident>§tokens_used: Vec<([u8; 16], Timestamp)>§known_good: Option<GenerationId>§live_tested: Option<GenerationId>§accepted_baseline: Option<GenerationId>§security_floor: Option<GenerationId>§external: Option<(u64, Hash)>The last accepted external document’s (sequence, digest) (B-16).
interlock: IdMap<InterlockEntry>§last_reconciliation: Option<Reconciliation>§agents: Vec<(String, [u8; 16], u32)>Every agent started, in order: (name, instance, the uid that started it). A peer is matched by its instance, never its name (I24).
hold_events: Vec<(UnitId, bool)>§12d: every hold applied (true) and lifted (false), in order; the
current holds are holds(). Append-only, so the fold needs no
comparison of units (and no new trusted helper). A journal from before
holds replays to none.
Implementations§
Source§impl Ledger
impl Ledger
Sourcepub fn well_formed(&self) -> bool
pub fn well_formed(&self) -> bool
The ledger invariant, checked: used on a checkpoint read from disk.
pub fn validate(&self, e: &Entry) -> Result<(), LedgerError>
Source§impl Ledger
impl Ledger
Sourcepub fn apply(&mut self, e: Entry) -> Result<(), LedgerError>
pub fn apply(&mut self, e: Entry) -> Result<(), LedgerError>
Validate, then apply. The record is consumed: the ledger keeps its parts.
Sourcepub fn add_interlock(&mut self, entry: InterlockEntry)
pub fn add_interlock(&mut self, entry: InterlockEntry)
Mark a transaction RecoveryFailed from the sentinel, when the journal itself could not take the record (§12c).
fn apply_valid(&mut self, e: Entry)
fn apply_prepared(&mut self, t: Transaction)
fn apply_advance( &mut self, txn: TxnId, epoch: u64, to: TxnState, note: String, withdrawn_for: Option<TxnId>, )
fn apply_takeover(&mut self, txn: TxnId, from_epoch: u64, lease: Lease)
fn apply_renew( &mut self, txn: TxnId, epoch: u64, at: Timestamp, worker_pid: Option<u32>, )
fn apply_op_begin(&mut self, op: OpId, call: String)
fn apply_op_ack(&mut self, op: OpId, outcome: Outcome)
Source§impl Ledger
impl Ledger
pub fn epoch(&self, txn: TxnId) -> Option<u64>
pub fn state(&self, txn: TxnId) -> Option<TxnState>
pub fn path(&self, txn: TxnId) -> Option<&[String]>
pub fn interlocked(&self) -> bool
Sourcepub fn agent_for(&self, name: &str, instance: [u8; 16]) -> Option<u32>
pub fn agent_for(&self, name: &str, instance: [u8; 16]) -> Option<u32>
The uid the agent name’s running instance acts for (§11, I24):
the start that journaled that very instance under that name. A zero
instance matches nothing.
Sourcepub fn agent_owner(&self, name: &str) -> Option<u32>
pub fn agent_owner(&self, name: &str) -> Option<u32>
Who started the last instance under name, for a refusal’s message.