pub struct MerkleTree<D: KeyValueDB, P: PoolParams> { /* private fields */ }
Implementations§
Source§impl<P: PoolParams> MerkleTree<InMemory, P>
impl<P: PoolParams> MerkleTree<InMemory, P>
pub fn new_test(params: P) -> MerkleTree<MemoryDatabase, P>
Source§impl<D: KeyValueDB, P: PoolParams> MerkleTree<D, P>
impl<D: KeyValueDB, P: PoolParams> MerkleTree<D, P>
pub fn new(db: D, params: P) -> Self
Sourcepub fn add_hash_at_height(
&mut self,
height: u32,
index: u64,
hash: Hash<P::Fr>,
temporary: bool,
)
pub fn add_hash_at_height( &mut self, height: u32, index: u64, hash: Hash<P::Fr>, temporary: bool, )
Add hash for an element with a certain index at a certain height
Set temporary
to true if you want this leaf and all unneeded connected nodes to be removed
during cleanup.
pub fn add_hash(&mut self, index: u64, hash: Hash<P::Fr>, temporary: bool)
pub fn append_hash(&mut self, hash: Hash<P::Fr>, temporary: bool) -> u64
pub fn add_leafs_and_commitments( &mut self, leafs: Vec<(u64, Vec<Hash<P::Fr>>)>, commitments: Vec<(u64, Hash<P::Fr>)>, )
pub fn add_hashes<I>(&mut self, start_index: u64, hashes: I)
pub fn get(&self, height: u32, index: u64) -> Hash<P::Fr>
pub fn last_leaf(&self) -> Hash<P::Fr>
pub fn get_root(&self) -> Hash<P::Fr>
pub fn get_root_after_virtual<I>(&self, new_commitments: I) -> Hash<P::Fr>
pub fn get_root_optimistic( &self, virtual_nodes: &mut HashMap<(u32, u64), Hash<P::Fr>>, update_boundaries: &UpdateBoundaries, ) -> Hash<P::Fr>
pub fn get_opt(&self, height: u32, index: u64) -> Option<Hash<P::Fr>>
pub fn get_proof_unchecked<const H: usize>( &self, index: u64, ) -> MerkleProof<P::Fr, H>
pub fn get_leaf_proof( &self, index: u64, ) -> Option<MerkleProof<P::Fr, { constants::HEIGHT }>>
pub fn get_proof_after_virtual<I>( &self, new_hashes: I, ) -> Vec<MerkleProof<P::Fr, { constants::HEIGHT }>>
pub fn get_proof_virtual_index<I>( &self, index: u64, new_hashes: I, ) -> Option<MerkleProof<P::Fr, { constants::HEIGHT }>>
pub fn get_virtual_subtree<I1, I2>(
&self,
new_hashes: I1,
new_commitments: I2,
) -> (HashMap<(u32, u64), Hash<P::Fr>>, UpdateBoundaries)where
I1: IntoIterator<Item = (u64, Vec<Hash<P::Fr>>)>,
I2: IntoIterator<Item = (u64, Hash<P::Fr>)>,
pub fn get_proof_optimistic_index( &self, index: u64, virtual_nodes: &mut HashMap<(u32, u64), Hash<P::Fr>>, update_boundaries: &UpdateBoundaries, ) -> Option<MerkleProof<P::Fr, { constants::HEIGHT }>>
pub fn get_virtual_node( &self, height: u32, index: u64, virtual_nodes: &mut HashMap<(u32, u64), Hash<P::Fr>>, new_hashes_left_index: u64, new_hashes_right_index: u64, ) -> Hash<P::Fr>
pub fn clean(&mut self) -> u64
pub fn clean_before_index(&mut self, clean_before_index: u64) -> u64
pub fn rollback(&mut self, rollback_index: u64) -> Option<u64>
pub fn get_all_nodes(&self) -> Vec<Node<P::Fr>>
pub fn get_leaves(&self) -> Vec<Node<P::Fr>>
pub fn get_leaves_after(&self, index: u64) -> Vec<Node<P::Fr>>
pub fn next_index(&self) -> u64
Auto Trait Implementations§
impl<D, P> Freeze for MerkleTree<D, P>
impl<D, P> RefUnwindSafe for MerkleTree<D, P>
impl<D, P> Send for MerkleTree<D, P>
impl<D, P> Sync for MerkleTree<D, P>
impl<D, P> Unpin for MerkleTree<D, P>
impl<D, P> UnwindSafe for MerkleTree<D, P>
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
Source§impl<Out, S> FromSeed<S> for Outwhere
S: SeedBoxGen<Out>,
impl<Out, S> FromSeed<S> for Outwhere
S: SeedBoxGen<Out>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more