pub struct Mmr { /* private fields */ }
Expand description
A fully materialized Merkle Mountain Range, with every tree in the forest and all their elements.
Since this is a full representation of the MMR, elements are never removed and the MMR will
grow roughly O(2n)
in number of leaf elements.
Implementations§
source§impl Mmr
impl Mmr
sourcepub const fn forest(&self) -> usize
pub const fn forest(&self) -> usize
Returns the MMR forest representation.
The forest value has the following interpretations:
- its value is the number of elements in the forest
- bit count corresponds to the number of trees in the forest
- each true bit position determines the depth of a tree in the forest
sourcepub fn open(
&self,
pos: usize,
target_forest: usize,
) -> Result<MmrProof, MmrError>
pub fn open( &self, pos: usize, target_forest: usize, ) -> Result<MmrProof, MmrError>
Given a leaf position, returns the Merkle path to its corresponding peak. If the position is greater-or-equal than the tree size an error is returned.
Note: The leaf position is the 0-indexed number corresponding to the order the leaves were added, this corresponds to the MMR size prior to adding the element. So the 1st element has position 0, the second position 1, and so on.
sourcepub fn get(&self, pos: usize) -> Result<RpoDigest, MmrError>
pub fn get(&self, pos: usize) -> Result<RpoDigest, MmrError>
Returns the leaf value at position pos
.
Note: The leaf position is the 0-indexed number corresponding to the order the leaves were added, this corresponds to the MMR size prior to adding the element. So the 1st element has position 0, the second position 1, and so on.
sourcepub fn peaks(&self, forest: usize) -> Result<MmrPeaks, MmrError>
pub fn peaks(&self, forest: usize) -> Result<MmrPeaks, MmrError>
Returns an peaks of the MMR for the version specified by forest
.
sourcepub fn get_delta(
&self,
from_forest: usize,
to_forest: usize,
) -> Result<MmrDelta, MmrError>
pub fn get_delta( &self, from_forest: usize, to_forest: usize, ) -> Result<MmrDelta, MmrError>
Compute the required update to original_forest
.
The result is a packed sequence of the authentication elements required to update the trees that have been merged together, followed by the new peaks of the Mmr.
sourcepub fn inner_nodes(&self) -> MmrNodes<'_>
pub fn inner_nodes(&self) -> MmrNodes<'_>
An iterator over inner nodes in the MMR. The order of iteration is unspecified.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mmr
impl RefUnwindSafe for Mmr
impl Send for Mmr
impl Sync for Mmr
impl Unpin for Mmr
impl UnwindSafe for Mmr
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)