pub struct SparseMerkleTree<const BITS: u8>;
Expand description
Sparse Merkle Tree variant that has hash-sized leaves, with most leaves being empty
(have value [0u8; 32]
).
In contrast to a proper Balanced Merkle Tree, constant BITS
here specifies the max number of
leaves hypothetically possible in a tree (2^BITS, often untractable), rather than the number of
non-empty leaves actually present.
Implementations§
Source§impl<const BITS: u8> SparseMerkleTree<BITS>
impl<const BITS: u8> SparseMerkleTree<BITS>
Sourcepub fn compute_root_only<'a, Iter>(leaves: Iter) -> Option<[u8; 32]>
pub fn compute_root_only<'a, Iter>(leaves: Iter) -> Option<[u8; 32]>
Compute Merkle Tree root.
If provided iterator ends early, it means the rest of the leaves are empty.
There must be no Leaf::Occupied
for empty/unoccupied leaves or else they may result in
invalid root, Leaf::Empty
must be used instead.
Returns None
if too many leaves were provided.
Trait Implementations§
Auto Trait Implementations§
impl<const BITS: u8> Freeze for SparseMerkleTree<BITS>
impl<const BITS: u8> RefUnwindSafe for SparseMerkleTree<BITS>
impl<const BITS: u8> Send for SparseMerkleTree<BITS>
impl<const BITS: u8> Sync for SparseMerkleTree<BITS>
impl<const BITS: u8> Unpin for SparseMerkleTree<BITS>
impl<const BITS: u8> UnwindSafe for SparseMerkleTree<BITS>
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