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) -> Result<MmrProof, MmrError>
pub fn open(&self, pos: usize) -> Result<MmrProof, MmrError>
Returns an MmrProof for the leaf at the specified position.
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.
§Errors
Returns an error if the specified leaf position is out of bounds for this MMR.
sourcepub fn open_at(&self, pos: usize, forest: usize) -> Result<MmrProof, MmrError>
pub fn open_at(&self, pos: usize, forest: usize) -> Result<MmrProof, MmrError>
Returns an MmrProof for the leaf at the specified position using the state of the MMR
at the specified forest
.
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.
§Errors
Returns an error if:
- The specified leaf position is out of bounds for this MMR.
- The specified
forest
value is not valid for this MMR.
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_at(&self, forest: usize) -> Result<MmrPeaks, MmrError>
pub fn peaks_at(&self, forest: usize) -> Result<MmrPeaks, MmrError>
Returns the peaks of the MMR at the state specified by forest
.
§Errors
Returns an error if the specified forest
value is not valid for this MMR.
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
)