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
impl OpLog
Sourcepub fn append(&mut self, entry: Entry) -> Result<bool, OpLogError>
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
nextlinks are no longer heads (they have a successor). - Returns true if the entry was newly inserted.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the log is empty (should never be — always has genesis).
Sourcepub fn entries_since(&self, known_hash: Option<&Hash>) -> Vec<&Entry>
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).
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> 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