#[repr(C)]pub struct IndexedMerkleTree<'a, H, I, const HEIGHT: usize>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Pod,
usize: From<I>,{
pub merkle_tree: ConcurrentMerkleTree<'a, H, HEIGHT>,
pub changelog: CyclicBoundedVec<'a, RawIndexedElement<I>>,
/* private fields */
}Fields§
§merkle_tree: ConcurrentMerkleTree<'a, H, HEIGHT>§changelog: CyclicBoundedVec<'a, RawIndexedElement<I>>Implementations§
source§impl<'a, H, I, const HEIGHT: usize> IndexedMerkleTree<'a, H, I, HEIGHT>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Pod,
usize: From<I>,
impl<'a, H, I, const HEIGHT: usize> IndexedMerkleTree<'a, H, I, HEIGHT>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Pod,
usize: From<I>,
pub fn new( height: usize, changelog_size: usize, roots_size: usize, canopy_depth: usize, indexed_change_log_size: usize ) -> Result<Self, ConcurrentMerkleTreeError>
pub fn init(&mut self) -> Result<(), IndexedMerkleTreeError>
pub fn changelog_index(&self) -> usize
pub fn root_index(&self) -> usize
pub fn root(&self) -> [u8; 32]
sourcepub fn validate_proof(
&self,
leaf: &[u8; 32],
leaf_index: usize,
proof: &BoundedVec<'_, [u8; 32]>
) -> Result<(), IndexedMerkleTreeError>
pub fn validate_proof( &self, leaf: &[u8; 32], leaf_index: usize, proof: &BoundedVec<'_, [u8; 32]> ) -> Result<(), IndexedMerkleTreeError>
Checks whether the given Merkle proof for the given node (with index
i) is valid. The proof is valid when computing parent node hashes using
the whole path of the proof gives the same result as the given root.
pub fn patch_low_element( &mut self, low_element: &IndexedElement<I> ) -> Result<Option<(IndexedElement<I>, [u8; 32])>, IndexedMerkleTreeError>
pub fn update( &mut self, changelog_index: usize, new_element: IndexedElement<I>, low_element: IndexedElement<I>, low_element_next_value: BigUint, low_leaf_proof: &mut BoundedVec<'_, [u8; 32]> ) -> Result<(), IndexedMerkleTreeError>
sourcepub fn initialize_address_merkle_tree(
&mut self,
init_value: BigUint
) -> Result<(), IndexedMerkleTreeError>
pub fn initialize_address_merkle_tree( &mut self, init_value: BigUint ) -> Result<(), IndexedMerkleTreeError>
Initializes the address merkle tree with the given initial value. The initial value should be a high value since one needs to prove non-inclusion of an address prior to insertion. Thus, addresses with higher values than the initial value cannot be inserted.
Trait Implementations§
source§impl<'a, H, I, const HEIGHT: usize> Debug for IndexedMerkleTree<'a, H, I, HEIGHT>where
H: Hasher + Debug,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Pod + Debug,
usize: From<I>,
impl<'a, H, I, const HEIGHT: usize> Debug for IndexedMerkleTree<'a, H, I, HEIGHT>where
H: Hasher + Debug,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Pod + Debug,
usize: From<I>,
Auto Trait Implementations§
impl<'a, H, I, const HEIGHT: usize> Freeze for IndexedMerkleTree<'a, H, I, HEIGHT>
impl<'a, H, I, const HEIGHT: usize> RefUnwindSafe for IndexedMerkleTree<'a, H, I, HEIGHT>
impl<'a, H, I, const HEIGHT: usize> Send for IndexedMerkleTree<'a, H, I, HEIGHT>
impl<'a, H, I, const HEIGHT: usize> Sync for IndexedMerkleTree<'a, H, I, HEIGHT>
impl<'a, H, I, const HEIGHT: usize> Unpin for IndexedMerkleTree<'a, H, I, HEIGHT>
impl<'a, H, I, const HEIGHT: usize> !UnwindSafe for IndexedMerkleTree<'a, H, I, HEIGHT>
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<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