pub struct Ledger { /* private fields */ }Expand description
The append-only, Merkle-chained event ledger.
Implementations§
Source§impl Ledger
impl Ledger
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn records(&self) -> &[LedgerRecord]
Sourcepub fn append(&mut self, event: LedgerEvent) -> Result<String>
pub fn append(&mut self, event: LedgerEvent) -> Result<String>
Append an event, extending the Merkle chain. Returns the new head.
Sourcepub fn record_observation(&mut self, content: &[u8]) -> Result<String>
pub fn record_observation(&mut self, content: &[u8]) -> Result<String>
Record a nondeterministic observation before it is used (R2). Returns the observation handle (content address).
Sourcepub fn has_observation(&self, handle: &str) -> bool
pub fn has_observation(&self, handle: &str) -> bool
Whether an observation handle has a ledger record.
Sourcepub fn commit_transition(
&mut self,
event: LedgerEvent,
referenced_observations: &[String],
) -> Result<String>
pub fn commit_transition( &mut self, event: LedgerEvent, referenced_observations: &[String], ) -> Result<String>
The kernel-refusal rule: refuse to commit a transition that references an observation lacking a ledger record (PSP-8 System 11). Returns an error naming the first unrecorded handle.
Sourcepub fn verify_chain(&self) -> Result<()>
pub fn verify_chain(&self) -> Result<()>
Verify the Merkle chain end to end (tamper detection).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.