Struct light_indexed_merkle_tree::IndexedMerkleTree

source ·
#[repr(C)]
pub struct IndexedMerkleTree<'a, H, I, const HEIGHT: usize>{ 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>

source

pub fn new( height: usize, changelog_size: usize, roots_size: usize, canopy_depth: usize, indexed_change_log_size: usize ) -> Result<Self, ConcurrentMerkleTreeError>

source

pub fn init(&mut self) -> Result<(), IndexedMerkleTreeError>

source

pub fn changelog_index(&self) -> usize

source

pub fn root_index(&self) -> usize

source

pub fn root(&self) -> [u8; 32]

source

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.

source

pub fn patch_low_element( &mut self, low_element: &IndexedElement<I> ) -> Result<Option<(IndexedElement<I>, [u8; 32])>, IndexedMerkleTreeError>

source

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>

source

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>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, H, I, const HEIGHT: usize> Freeze for IndexedMerkleTree<'a, H, I, HEIGHT>
where usize: Sized,

§

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>
where usize: Sized, I: Send, H: Send,

§

impl<'a, H, I, const HEIGHT: usize> Sync for IndexedMerkleTree<'a, H, I, HEIGHT>
where usize: Sized, I: Sync, H: Sync,

§

impl<'a, H, I, const HEIGHT: usize> Unpin for IndexedMerkleTree<'a, H, I, HEIGHT>
where usize: Sized, I: Unpin, H: Unpin,

§

impl<'a, H, I, const HEIGHT: usize> !UnwindSafe for IndexedMerkleTree<'a, H, I, HEIGHT>

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

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<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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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