pub struct ConcurrentMerkleTreeCopy<H, const HEIGHT: usize>(/* private fields */)
where
H: Hasher;
Implementations§
Source§impl<H, const HEIGHT: usize> ConcurrentMerkleTreeCopy<H, HEIGHT>where
H: Hasher,
impl<H, const HEIGHT: usize> ConcurrentMerkleTreeCopy<H, HEIGHT>where
H: Hasher,
pub fn struct_from_bytes_copy( bytes: &[u8], ) -> Result<(ConcurrentMerkleTree<H, HEIGHT>, usize), ConcurrentMerkleTreeError>
pub fn from_bytes_copy(bytes: &[u8]) -> Result<Self, ConcurrentMerkleTreeError>
Methods from Deref<Target = ConcurrentMerkleTree<H, HEIGHT>>§
Sourcepub fn changelog_index(&self) -> usize
pub fn changelog_index(&self) -> usize
Returns the index of the current changelog entry.
Sourcepub fn root_index(&self) -> usize
pub fn root_index(&self) -> usize
Returns the index of the current root in the tree’s root buffer.
pub fn current_index(&self) -> usize
pub fn next_index(&self) -> usize
pub fn sequence_number(&self) -> usize
pub fn rightmost_leaf(&self) -> [u8; 32]
pub fn update_proof_from_canopy( &self, leaf_index: usize, proof: &mut BoundedVec<[u8; 32]>, ) -> Result<(), ConcurrentMerkleTreeError>
Sourcepub fn changelog_entries(
&self,
changelog_index: usize,
) -> Result<Skip<CyclicBoundedVecIterator<'_, ChangelogEntry<HEIGHT>>>, ConcurrentMerkleTreeError>
pub fn changelog_entries( &self, changelog_index: usize, ) -> Result<Skip<CyclicBoundedVecIterator<'_, ChangelogEntry<HEIGHT>>>, ConcurrentMerkleTreeError>
Returns an iterator with changelog entries newer than the requested
changelog_index
.
Sourcepub fn update_proof_from_changelog(
&self,
changelog_index: usize,
leaf_index: usize,
proof: &mut BoundedVec<[u8; 32]>,
) -> Result<(), ConcurrentMerkleTreeError>
pub fn update_proof_from_changelog( &self, changelog_index: usize, leaf_index: usize, proof: &mut BoundedVec<[u8; 32]>, ) -> Result<(), ConcurrentMerkleTreeError>
Updates the given Merkle proof.
The update is performed by checking whether there are any new changelog entries and whether they contain changes which affect the current proof. To be precise, for each changelog entry, it’s done in the following steps:
- Check if the changelog entry was directly updating the
leaf_index
we are trying to update.- If no (we check that condition first, since it’s more likely),
it means that there is a change affecting the proof, but not the
leaf.
Check which element from our proof was affected by the change
(using the
critbit_index
method) and update it (copy the new element from the changelog to our updated proof). - If yes, it means that the same leaf we want to update was already updated. In such case, updating the proof is not possible.
- If no (we check that condition first, since it’s more likely),
it means that there is a change affecting the proof, but not the
leaf.
Check which element from our proof was affected by the change
(using the
Sourcepub fn validate_proof(
&self,
leaf: &[u8; 32],
leaf_index: usize,
proof: &BoundedVec<[u8; 32]>,
) -> Result<(), ConcurrentMerkleTreeError>
pub fn validate_proof( &self, leaf: &[u8; 32], leaf_index: usize, proof: &BoundedVec<[u8; 32]>, ) -> Result<(), ConcurrentMerkleTreeError>
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
.
Trait Implementations§
Source§impl<H, const HEIGHT: usize> Debug for ConcurrentMerkleTreeCopy<H, HEIGHT>
impl<H, const HEIGHT: usize> Debug for ConcurrentMerkleTreeCopy<H, HEIGHT>
Auto Trait Implementations§
impl<H, const HEIGHT: usize> Freeze for ConcurrentMerkleTreeCopy<H, HEIGHT>
impl<H, const HEIGHT: usize> RefUnwindSafe for ConcurrentMerkleTreeCopy<H, HEIGHT>where
H: RefUnwindSafe,
impl<H, const HEIGHT: usize> !Send for ConcurrentMerkleTreeCopy<H, HEIGHT>
impl<H, const HEIGHT: usize> !Sync for ConcurrentMerkleTreeCopy<H, HEIGHT>
impl<H, const HEIGHT: usize> Unpin for ConcurrentMerkleTreeCopy<H, HEIGHT>where
H: Unpin,
impl<H, const HEIGHT: usize> UnwindSafe for ConcurrentMerkleTreeCopy<H, HEIGHT>where
H: UnwindSafe,
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