Struct MerkleTree
pub struct MerkleTree<T> {
pub algorithm: &'static Algorithm,
/* 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: &'static Algorithm
The hashing algorithm used by this Merkle tree
Implementations§
§impl<T> MerkleTree<T>
impl<T> MerkleTree<T>
pub fn from_vec(algorithm: &'static Algorithm, values: Vec<T>) -> MerkleTree<T>where
T: Hashable,
pub fn from_vec(algorithm: &'static Algorithm, values: Vec<T>) -> MerkleTree<T>where
T: Hashable,
Constructs a Merkle Tree from a vector of data blocks.
Returns None
if values
is empty.
pub fn gen_proof(&self, value: T) -> Option<Proof<T>>where
T: Hashable,
pub fn gen_proof(&self, value: T) -> Option<Proof<T>>where
T: Hashable,
Generate an inclusion proof for the given value.
Returns None
if the given value is not found in the tree.
pub fn gen_nth_proof(&self, n: usize) -> Option<Proof<T>>where
T: Hashable + Clone,
pub fn gen_nth_proof(&self, n: usize) -> Option<Proof<T>>where
T: Hashable + Clone,
Generate an inclusion proof for the n
-th leaf value.
pub fn iter(&self) -> LeavesIterator<'_, T>
pub fn iter(&self) -> LeavesIterator<'_, T>
Creates an Iterator
over the values contained in this Merkle tree.
Trait Implementations§
§impl<T> Clone for MerkleTree<T>where
T: Clone,
impl<T> Clone for MerkleTree<T>where
T: Clone,
§fn clone(&self) -> MerkleTree<T>
fn clone(&self) -> MerkleTree<T>
Returns a copy 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 more§impl<T> Debug for MerkleTree<T>where
T: Debug,
impl<T> Debug for MerkleTree<T>where
T: Debug,
§impl<T> Hash for MerkleTree<T>where
T: Hash,
impl<T> Hash for MerkleTree<T>where
T: Hash,
§impl<'a, T> IntoIterator for &'a MerkleTree<T>
impl<'a, T> IntoIterator for &'a MerkleTree<T>
§fn into_iter(self) -> <&'a MerkleTree<T> as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a MerkleTree<T> as IntoIterator>::IntoIter
Creates a borrowing Iterator
over the values contained in this Merkle tree.
§impl<T> IntoIterator for MerkleTree<T>
impl<T> IntoIterator for MerkleTree<T>
§fn into_iter(self) -> <MerkleTree<T> as IntoIterator>::IntoIter
fn into_iter(self) -> <MerkleTree<T> as IntoIterator>::IntoIter
Creates a consuming iterator, that is, one that moves each value out of the Merkle tree. The tree cannot be used after calling this.
§impl<T> Ord for MerkleTree<T>where
T: Ord,
impl<T> Ord for MerkleTree<T>where
T: Ord,
§impl<T> PartialEq for MerkleTree<T>where
T: PartialEq,
impl<T> PartialEq for MerkleTree<T>where
T: PartialEq,
§impl<T> PartialOrd for MerkleTree<T>where
T: Ord,
impl<T> PartialOrd for MerkleTree<T>where
T: Ord,
impl<T> Eq for MerkleTree<T>where
T: Eq,
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