pub struct MerkleTree<T> {
pub algorithm: Sha3,
/* private fields */
}
Expand description
A Merkle tree is a binary tree, with values of type T
at the leafs,
and where every internal node holds the hash of the concatenation of the hashes of its children nodes.
Fields§
§algorithm: Sha3
The hashing algorithm used by this Merkle tree
Implementations§
Source§impl<T> MerkleTree<T>
impl<T> MerkleTree<T>
Sourcepub fn from_vec<H>(algorithm: Sha3, values: Vec<T>) -> Self
pub fn from_vec<H>(algorithm: Sha3, values: Vec<T>) -> Self
Constructs a Merkle Tree from a vector of data blocks.
Returns None
if values
is empty.
Sourcepub fn gen_proof<H>(&self, value: T) -> Option<Proof<T>>
pub fn gen_proof<H>(&self, value: T) -> Option<Proof<T>>
Generate an inclusion proof for the given value.
Returns None
if the given value is not found in the tree.
Sourcepub fn iter(&self) -> LeavesIterator<'_, T> ⓘ
pub fn iter(&self) -> LeavesIterator<'_, T> ⓘ
Creates an Iterator
over the values contained in this Merkle tree.
Trait Implementations§
Source§impl<T: Clone> Clone for MerkleTree<T>
impl<T: Clone> Clone for MerkleTree<T>
Source§fn clone(&self) -> MerkleTree<T>
fn clone(&self) -> MerkleTree<T>
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 moreSource§impl<'a, T> IntoIterator for &'a MerkleTree<T>
impl<'a, T> IntoIterator for &'a MerkleTree<T>
Source§impl<T> IntoIterator for MerkleTree<T>
impl<T> IntoIterator for MerkleTree<T>
Auto Trait Implementations§
impl<T> Freeze for MerkleTree<T>where
T: Freeze,
impl<T> RefUnwindSafe for MerkleTree<T>where
T: RefUnwindSafe,
impl<T> Send for MerkleTree<T>where
T: Send,
impl<T> Sync for MerkleTree<T>where
T: Sync,
impl<T> Unpin for MerkleTree<T>where
T: Unpin,
impl<T> UnwindSafe for MerkleTree<T>where
T: UnwindSafe,
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