pub struct MerkleNode {
pub hash: [u8; 32],
pub children: BTreeMap<String, [u8; 32]>,
pub is_leaf: bool,
}Expand description
A node in the path-based Merkle tree.
Fields§
§hash: [u8; 32]Hash of this node (computed from children or leaf value)
children: BTreeMap<String, [u8; 32]>Child segment -> child hash (empty for leaves)
is_leaf: boolTrue if this is a leaf (actual item), false if interior node
Implementations§
Source§impl MerkleNode
impl MerkleNode
Sourcepub fn interior(children: BTreeMap<String, [u8; 32]>) -> Self
pub fn interior(children: BTreeMap<String, [u8; 32]>) -> Self
Create an interior node, computing hash from children.
Sourcepub fn recompute_hash(&mut self)
pub fn recompute_hash(&mut self)
Recompute hash after children changed.
Sourcepub fn set_child(&mut self, segment: String, child_hash: [u8; 32]) -> bool
pub fn set_child(&mut self, segment: String, child_hash: [u8; 32]) -> bool
Add or update a child, returns true if hash changed.
Sourcepub fn remove_child(&mut self, segment: &str) -> bool
pub fn remove_child(&mut self, segment: &str) -> bool
Remove a child, returns true if hash changed.
Trait Implementations§
Source§impl Clone for MerkleNode
impl Clone for MerkleNode
Source§fn clone(&self) -> MerkleNode
fn clone(&self) -> MerkleNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MerkleNode
impl RefUnwindSafe for MerkleNode
impl Send for MerkleNode
impl Sync for MerkleNode
impl Unpin for MerkleNode
impl UnwindSafe for MerkleNode
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<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