pub struct MerkleTree { /* private fields */ }Expand description
RFC 6962-compatible Merkle tree.
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn from_leaves<T>(leaves: &[T]) -> Result<MerkleTree, Error>
pub fn from_leaves<T>(leaves: &[T]) -> Result<MerkleTree, Error>
Build a Merkle tree from leaf data.
Returns Err(Error::EmptyTree) if the slice is empty.
Sourcepub fn from_hashes(leaf_hashes: Vec<Hash>) -> Result<MerkleTree, Error>
pub fn from_hashes(leaf_hashes: Vec<Hash>) -> Result<MerkleTree, Error>
Build a Merkle tree from pre-hashed leaves.
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Get the number of leaves.
Sourcepub fn inclusion_proof(&self, leaf_index: usize) -> Result<MerkleProof, Error>
pub fn inclusion_proof(&self, leaf_index: usize) -> Result<MerkleProof, Error>
Generate an inclusion proof for a leaf at the given index.
Trait Implementations§
Source§impl Clone for MerkleTree
impl Clone for MerkleTree
Source§fn clone(&self) -> MerkleTree
fn clone(&self) -> MerkleTree
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 MerkleTree
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnsafeUnpin 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