Skip to main content

Ledger

Struct Ledger 

Source
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

Source

pub fn well_formed(&self) -> bool

The ledger invariant, checked: used on a checkpoint read from disk.

Source

pub fn validate(&self, e: &Entry) -> Result<(), LedgerError>

Source§

impl Ledger

Source

pub fn apply(&mut self, e: Entry) -> Result<(), LedgerError>

Validate, then apply. The record is consumed: the ledger keeps its parts.

Source

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).

Source

fn apply_valid(&mut self, e: Entry)

Source

fn apply_prepared(&mut self, t: Transaction)

Source

fn apply_advance( &mut self, txn: TxnId, epoch: u64, to: TxnState, note: String, withdrawn_for: Option<TxnId>, )

Source

fn apply_takeover(&mut self, txn: TxnId, from_epoch: u64, lease: Lease)

Source

fn apply_renew( &mut self, txn: TxnId, epoch: u64, at: Timestamp, worker_pid: Option<u32>, )

Source

fn apply_op_begin(&mut self, op: OpId, call: String)

Source

fn apply_op_ack(&mut self, op: OpId, outcome: Outcome)

Source§

impl Ledger

Source

pub fn epoch(&self, txn: TxnId) -> Option<u64>

Source

pub fn state(&self, txn: TxnId) -> Option<TxnState>

Source

pub fn path(&self, txn: TxnId) -> Option<&[String]>

Source

pub fn interlocked(&self) -> bool

Source

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.

Source

pub fn agent_owner(&self, name: &str) -> Option<u32>

Who started the last instance under name, for a refusal’s message.

Source

pub fn holds(&self) -> BTreeSet<UnitId>

§12d: the units whose traffic the journal says is held now: the last event for each is an apply. The recovery source of truth after a restart (the daemon reconciles it with the host, failing closed).

Trait Implementations§

Source§

impl Clone for Ledger

Source§

fn clone(&self) -> Ledger

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Ledger

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Ledger

Source§

fn default() -> Ledger

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Ledger

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Ledger

Source§

fn eq(&self, other: &Ledger) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Ledger

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Ledger

Source§

impl StructuralPartialEq for Ledger

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,