pub struct MerkleTree {
pub root: B256,
/* private fields */
}
Expand description
A Merkle tree implementation supporting insertion of leaves, tree construction, proof generation, and proof verification.
Fields§
§root: B256
The root hash of the Merkle tree.
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty MerkleTree
.
Sourcepub fn set_sort(&mut self, sort: bool)
pub fn set_sort(&mut self, sort: bool)
Sets whether the leaves should be sorted before tree construction.
Sourcepub fn finish(&mut self)
pub fn finish(&mut self)
Finalizes the tree construction by building all layers and computing the root hash.
If the tree has already been constructed, this method will do nothing.
Sourcepub fn create_proof(&self, leaf: &B256) -> Option<MerkleProof>
pub fn create_proof(&self, leaf: &B256) -> Option<MerkleProof>
Generates a Merkle proof for a given leaf.
An Option
containing the MerkleProof
if the leaf is found, or None
if not.
Sourcepub fn verify_proof(proof: &MerkleProof) -> bool
pub fn verify_proof(proof: &MerkleProof) -> bool
Trait Implementations§
Source§impl Debug for MerkleTree
impl Debug for MerkleTree
Source§impl Default for MerkleTree
impl Default for MerkleTree
Source§fn default() -> Self
fn default() -> Self
Creates a new empty MerkleTree
with default values.
Auto Trait Implementations§
impl Freeze for MerkleTree
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnwindSafe for MerkleTree
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