Struct MerkleTree

Source
pub struct MerkleTree<D: KeyValueDB, P: PoolParams> { /* private fields */ }

Implementations§

Source§

impl<P: PoolParams> MerkleTree<InMemory, P>

Source

pub fn new_test(params: P) -> MerkleTree<MemoryDatabase, P>

Source§

impl<D: KeyValueDB, P: PoolParams> MerkleTree<D, P>

Source

pub fn new(db: D, params: P) -> Self

Source

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.

Source

pub fn add_hash(&mut self, index: u64, hash: Hash<P::Fr>, temporary: bool)

Source

pub fn append_hash(&mut self, hash: Hash<P::Fr>, temporary: bool) -> u64

Source

pub fn add_leafs_and_commitments( &mut self, leafs: Vec<(u64, Vec<Hash<P::Fr>>)>, commitments: Vec<(u64, Hash<P::Fr>)>, )

Source

pub fn add_hashes<I>(&mut self, start_index: u64, hashes: I)
where I: IntoIterator<Item = Hash<P::Fr>>,

Source

pub fn get(&self, height: u32, index: u64) -> Hash<P::Fr>

Source

pub fn last_leaf(&self) -> Hash<P::Fr>

Source

pub fn get_root(&self) -> Hash<P::Fr>

Source

pub fn get_root_after_virtual<I>(&self, new_commitments: I) -> Hash<P::Fr>
where I: IntoIterator<Item = Hash<P::Fr>>,

Source

pub fn get_root_optimistic( &self, virtual_nodes: &mut HashMap<(u32, u64), Hash<P::Fr>>, update_boundaries: &UpdateBoundaries, ) -> Hash<P::Fr>

Source

pub fn get_opt(&self, height: u32, index: u64) -> Option<Hash<P::Fr>>

Source

pub fn get_proof_unchecked<const H: usize>( &self, index: u64, ) -> MerkleProof<P::Fr, H>

Source

pub fn get_leaf_proof( &self, index: u64, ) -> Option<MerkleProof<P::Fr, { constants::HEIGHT }>>

Source

pub fn get_proof_after_virtual<I>( &self, new_hashes: I, ) -> Vec<MerkleProof<P::Fr, { constants::HEIGHT }>>
where I: IntoIterator<Item = Hash<P::Fr>>,

Source

pub fn get_proof_virtual_index<I>( &self, index: u64, new_hashes: I, ) -> Option<MerkleProof<P::Fr, { constants::HEIGHT }>>
where I: IntoIterator<Item = Hash<P::Fr>>,

Source

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>)>,

Source

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 }>>

Source

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>

Source

pub fn clean(&mut self) -> u64

Source

pub fn clean_before_index(&mut self, clean_before_index: u64) -> u64

Source

pub fn rollback(&mut self, rollback_index: u64) -> Option<u64>

Source

pub fn get_all_nodes(&self) -> Vec<Node<P::Fr>>

Source

pub fn get_leaves(&self) -> Vec<Node<P::Fr>>

Source

pub fn get_leaves_after(&self, index: u64) -> Vec<Node<P::Fr>>

Source

pub fn next_index(&self) -> u64

Auto Trait Implementations§

§

impl<D, P> Freeze for MerkleTree<D, P>
where D: Freeze, P: Freeze,

§

impl<D, P> RefUnwindSafe for MerkleTree<D, P>

§

impl<D, P> Send for MerkleTree<D, P>
where P: Send, <P as PoolParams>::Fr: Send,

§

impl<D, P> Sync for MerkleTree<D, P>
where P: Sync, <P as PoolParams>::Fr: Sync,

§

impl<D, P> Unpin for MerkleTree<D, P>
where D: Unpin, P: Unpin, <P as PoolParams>::Fr: Unpin,

§

impl<D, P> UnwindSafe for MerkleTree<D, P>
where D: UnwindSafe, P: UnwindSafe, <P as PoolParams>::Fr: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Out, S> FromSeed<S> for Out
where S: SeedBoxGen<Out>,

Source§

fn from_seed(seed: &[u8]) -> Out

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V