pub struct MerkleDigest {
pub entries: Vec<DigestEntry>,
pub root_hash: u64,
}Expand description
A compact, sortable digest of local state suitable for peer comparison.
Entries are always kept sorted by key so that diff_keys is deterministic
and independent of insertion order.
Fields§
§entries: Vec<DigestEntry>Sorted (by key) snapshot of local state entries.
root_hash: u64XOR-fold of all per-entry (key_hash XOR value_hash XOR version) tuples.
Implementations§
Source§impl MerkleDigest
impl MerkleDigest
Sourcepub fn from_sorted(entries: Vec<DigestEntry>) -> Self
pub fn from_sorted(entries: Vec<DigestEntry>) -> Self
Compute a MerkleDigest from an already-sorted list of entries.
Assumes entries is sorted by key; callers must ensure this invariant.
Sourcepub fn matches(&self, other: &MerkleDigest) -> bool
pub fn matches(&self, other: &MerkleDigest) -> bool
Returns true when both digests share the same root hash, meaning all
keys, values, and versions are identical.
Sourcepub fn diff_keys(&self, other: &MerkleDigest) -> Vec<String>
pub fn diff_keys(&self, other: &MerkleDigest) -> Vec<String>
Return the set of keys that differ between self and other.
A key is included when:
- It exists in one digest but not the other.
- It exists in both but
value_hashorversiondiffer.
Trait Implementations§
Source§impl Clone for MerkleDigest
impl Clone for MerkleDigest
Source§fn clone(&self) -> MerkleDigest
fn clone(&self) -> MerkleDigest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MerkleDigest
impl Debug for MerkleDigest
impl Eq for MerkleDigest
Source§impl PartialEq for MerkleDigest
impl PartialEq for MerkleDigest
Source§fn eq(&self, other: &MerkleDigest) -> bool
fn eq(&self, other: &MerkleDigest) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for MerkleDigest
Auto Trait Implementations§
impl Freeze for MerkleDigest
impl RefUnwindSafe for MerkleDigest
impl Send for MerkleDigest
impl Sync for MerkleDigest
impl Unpin for MerkleDigest
impl UnsafeUnpin for MerkleDigest
impl UnwindSafe for MerkleDigest
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more