pub struct LedgerEntry {
pub seq: u64,
pub prev: Digest,
pub run: RunId,
pub step: StepId,
pub grant: GrantDelta,
pub cost: CostRecord,
pub evidence: Option<Evidence>,
pub journal: Option<JournalRef>,
pub isolation: Option<Isolation>,
}Expand description
λ — one append-only, hash-chained ledger record.
§Example
use boundgraph_core::{Canonical, CostRecord, Digest, GrantDelta, GrantSet,
LedgerEntry, RunId, StepId};
let run = RunId::new();
let step = StepId::new(Digest::of(b"step-1"));
let delta = GrantDelta::new(GrantSet::EMPTY, GrantSet::EMPTY, GrantSet::EMPTY);
let first = LedgerEntry::genesis(run, step, delta.clone(), CostRecord::default(), None, None);
let second = LedgerEntry::following(&first, step, delta, CostRecord::default(), None, None)?;
// Each entry commits to the one before it.
assert_eq!(second.prev, first.digest()?);
assert!(second.follows(&first)?);Fields§
§seq: u64Position in the chain, starting at zero and gapless.
prev: DigestDigest of entry seq - 1. The genesis entry links to all-zero.
run: RunIdWhich run this belongs to.
step: StepIdWhich step this records.
grant: GrantDeltaWhat was requested, granted, and attenuated.
cost: CostRecordWhat it cost.
evidence: Option<Evidence>The verdict, where the step reached one.
journal: Option<JournalRef>Where the journalled nondeterministic inputs live.
isolation: Option<Isolation>What actually confined the step, where the runner said (US-0508).
In the entry rather than beside it, because it is a fact about the
step’s authority and belongs where GrantDelta is: the chain
commits to it, so a confinement record cannot be edited afterwards
without giving itself away. That is the whole difference between “this
ran confined” being checkable and being trusted.
None means the runner did not say, and is deliberately distinct from
Confinement::NONE, which means it ran with
nothing enforced. Skipped when absent, so an entry from a runner that
says nothing encodes exactly as it did before this field existed and
every digest already written stays valid.
Implementations§
Source§impl LedgerEntry
impl LedgerEntry
Sourcepub fn genesis(
run: RunId,
step: StepId,
grant: GrantDelta,
cost: CostRecord,
evidence: Option<Evidence>,
journal: Option<JournalRef>,
) -> Self
pub fn genesis( run: RunId, step: StepId, grant: GrantDelta, cost: CostRecord, evidence: Option<Evidence>, journal: Option<JournalRef>, ) -> Self
The first entry in a chain.
Sourcepub fn following(
previous: &Self,
step: StepId,
grant: GrantDelta,
cost: CostRecord,
evidence: Option<Evidence>,
journal: Option<JournalRef>,
) -> Result<Self, CanonicalError>
pub fn following( previous: &Self, step: StepId, grant: GrantDelta, cost: CostRecord, evidence: Option<Evidence>, journal: Option<JournalRef>, ) -> Result<Self, CanonicalError>
The next entry after previous, linked to it by digest.
§Errors
Returns CanonicalError if previous cannot be canonically encoded,
which would make the link uncomputable.
Sourcepub fn confined_by(self, isolation: Isolation) -> Self
pub fn confined_by(self, isolation: Isolation) -> Self
Record what actually confined the step (US-0508).
A builder rather than a seventh constructor argument: the two
constructors are what every sink calls, most transitions are not an
execution, and a parameter that was None on five appends out of six
would be noise at every call site that never had one to give.
Setting it changes the entry’s digest, so this belongs before the entry is handed to a chain rather than after.
Sourcepub const fn confinement(&self) -> Option<Isolation>
pub const fn confinement(&self) -> Option<Isolation>
What confined this step, where the runner said.
None means unrecorded. See isolation: a step that
ran with nothing enforced returns Some.
Sourcepub const fn is_confinement_recorded(&self) -> bool
pub const fn is_confinement_recorded(&self) -> bool
Whether this entry records what confined the step at all.
Sourcepub const fn ran_virtualised(&self) -> bool
pub const fn ran_virtualised(&self) -> bool
Whether this step ran in a virtualising tier — what Profile C asks for.
false for a step whose confinement was never recorded, because an
unrecorded step is not evidence that anything virtualised it. A caller
that needs to tell the two apart reads
is_confinement_recorded.
Sourcepub fn follows(&self, previous: &Self) -> Result<bool, CanonicalError>
pub fn follows(&self, previous: &Self) -> Result<bool, CanonicalError>
Whether this entry genuinely follows previous.
Checks both the sequence number and the digest link. A gap or a broken link means the chain has been altered.
§Errors
Returns CanonicalError if previous cannot be canonically encoded.
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Whether this is the first entry in a chain.