pub struct MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,{ /* private fields */ }Expand description
An in-memory append-only Merkle tree implementation, supporting inclusion and consistency proofs. This stores leaf values, not just leaf hashes.
Implementations§
Source§impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
Sourcepub fn prove_consistency(&self, num_additions: usize) -> ConsistencyProof<H>
pub fn prove_consistency(&self, num_additions: usize) -> ConsistencyProof<H>
Produces a proof that this MemoryBackedTree is the result of appending num_additions items
to a prefix of this tree.
§Panics
Panics if num_additions >= self.len().
Source§impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
Sourcepub fn prove_inclusion(&self, idx: usize) -> InclusionProof<H>
pub fn prove_inclusion(&self, idx: usize) -> InclusionProof<H>
Source§impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
impl<H, T> MemoryBackedTree<H, T>where
H: Digest,
T: HashableLeaf,
pub fn new() -> Self
Sourcepub fn push(&mut self, new_val: T)
pub fn push(&mut self, new_val: T)
Appends the given item to the end of the list.
§Panics
Panics if self.len() > ⌊usize::MAX / 2⌋ - 1. Also panics if this tree is malformed,
e.g., deserialized from disk without passing a MemoryBackedTree::self_check.
Sourcepub fn self_check(&self) -> Result<(), SelfCheckError>
pub fn self_check(&self) -> Result<(), SelfCheckError>
Checks that this tree is well-formed. This can take a while if the tree is large. Run this if you’ve deserialized this tree and don’t trust the source. If a tree is malformed, other methods will panic or behave oddly.
Sourcepub fn root(&self) -> RootHash<H>
pub fn root(&self) -> RootHash<H>
Returns the root hash of this tree. The value and type uniquely describe this tree.
§Panics
Panics if this tree is malformed, e.g., deserialized from disk without passing a
MemoryBackedTree::self_check.
Trait Implementations§
Source§impl<H, T> Clone for MemoryBackedTree<H, T>
impl<H, T> Clone for MemoryBackedTree<H, T>
Source§fn clone(&self) -> MemoryBackedTree<H, T>
fn clone(&self) -> MemoryBackedTree<H, T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more