Skip to main content

OpLog

Struct OpLog 

Source
pub struct OpLog { /* private fields */ }
Expand description

In-memory Merkle-DAG operation log.

Append-only: entries are content-addressed and linked to their causal predecessors (the heads at time of write). The OpLog tracks heads, supports delta computation (entries_since), and topological sorting.

Implementations§

Source§

impl OpLog

Source

pub fn new(genesis: Entry) -> Self

Create a new OpLog with a genesis entry.

Source

pub fn append(&mut self, entry: Entry) -> Result<bool, OpLogError>

Append an entry to the log.

  • Verifies the entry hash is valid.
  • If the entry already exists (duplicate), returns false.
  • Updates heads: the entry’s next links are no longer heads (they have a successor).
  • Returns true if the entry was newly inserted.
Source

pub fn heads(&self) -> Vec<Hash>

Current DAG head hashes.

Source

pub fn get(&self, hash: &Hash) -> Option<&Entry>

Get an entry by hash.

Source

pub fn len(&self) -> usize

Total entries in the log.

Source

pub fn is_empty(&self) -> bool

Whether the log is empty (should never be — always has genesis).

Source

pub fn entries_since(&self, known_hash: Option<&Hash>) -> Vec<&Entry>

Return all entries reachable from current heads that are NOT reachable from (or equal to) known_hash.

This computes the delta a peer needs: “give me everything you have that I don’t, given that I already have known_hash and its ancestors.”

If known_hash is None, returns all entries (the entire log).

Source

pub fn topo_sort(&self, hashes: &HashSet<Hash>) -> Vec<&Entry>

Topological sort of the given set of entry hashes. Returns entries in causal order: parents before children.

Source

pub fn entries_as_of( &self, cutoff_physical: u64, cutoff_logical: u32, ) -> Vec<&Entry>

R-06: Get all entries with clock <= cutoff, in topological order. Returns a historical snapshot of the state at the given time.

Auto Trait Implementations§

§

impl Freeze for OpLog

§

impl RefUnwindSafe for OpLog

§

impl Send for OpLog

§

impl Sync for OpLog

§

impl Unpin for OpLog

§

impl UnsafeUnpin for OpLog

§

impl UnwindSafe for OpLog

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