pub struct MerkleTree<D: Digest> { /* private fields */ }Expand description
Flat, Fixed-Size, Read only Merkle Tree
Expects the length of leaves to be equal or near(less) to a power of two.
Implementations§
Source§impl<D: Digest + FixedOutputReset> MerkleTree<D>
impl<D: Digest + FixedOutputReset> MerkleTree<D>
Sourcepub fn new(data: &[Output<D>]) -> Self
pub fn new(data: &[Output<D>]) -> Self
Constructs a new Merkle tree from the given hash leaves.
Sourcepub fn new_unhashed(data: &[Output<D>]) -> UnhashedMerkleTree<D>
pub fn new_unhashed(data: &[Output<D>]) -> UnhashedMerkleTree<D>
Constructs a new Merkle tree from the given hash leaves, without hashing internal nodes.
Sourcepub fn contains(&self, leaf: &Output<D>) -> bool
pub fn contains(&self, leaf: &Output<D>) -> bool
Checks if the given leaf is contained in the Merkle tree
Sourcepub fn get_proof_iter(&self, leaf: &Output<D>) -> Option<SiblingIter<'_, D>>
pub fn get_proof_iter(&self, leaf: &Output<D>) -> Option<SiblingIter<'_, D>>
Get proof for a given leaf
Sourcepub fn as_raw_bytes(&self) -> &[u8] ⓘ
pub fn as_raw_bytes(&self) -> &[u8] ⓘ
Returns the raw bytes of the Merkle tree nodes
Sourcepub fn from_raw_bytes(bytes: &[u8]) -> Self
pub fn from_raw_bytes(bytes: &[u8]) -> Self
From raw bytes, reconstruct the Merkle tree
§Panics
- If the length of
bytesis not a multiple of the hash output size. - If the number of nodes implied by
bytesis not consistent with a valid Merkle tree structure.
Trait Implementations§
Source§impl<D: Clone + Digest> Clone for MerkleTree<D>
impl<D: Clone + Digest> Clone for MerkleTree<D>
Source§fn clone(&self) -> MerkleTree<D>
fn clone(&self) -> MerkleTree<D>
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<D> Freeze for MerkleTree<D>
impl<D> RefUnwindSafe for MerkleTree<D>
impl<D> Send for MerkleTree<D>
impl<D> Sync for MerkleTree<D>
impl<D> Unpin for MerkleTree<D>
impl<D> UnsafeUnpin for MerkleTree<D>
impl<D> UnwindSafe for MerkleTree<D>
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