Struct incrementalmerkletree::frontier::Frontier
source · pub struct Frontier<H, const DEPTH: u8> { /* private fields */ }
Expand description
A possibly-empty Merkle frontier.
Implementations§
source§impl<H, const DEPTH: u8> Frontier<H, DEPTH>
impl<H, const DEPTH: u8> Frontier<H, DEPTH>
sourcepub fn from_parts(
position: Position,
leaf: H,
ommers: Vec<H>
) -> Result<Self, FrontierError>
pub fn from_parts( position: Position, leaf: H, ommers: Vec<H> ) -> Result<Self, FrontierError>
Constructs a new frontier from its constituent parts.
Returns an error if the new frontier would exceed the maximum allowed depth or if the list of ommers provided is not consistent with the position of the leaf.
sourcepub fn value(&self) -> Option<&NonEmptyFrontier<H>>
pub fn value(&self) -> Option<&NonEmptyFrontier<H>>
Return the wrapped NonEmptyFrontier reference, or None if the frontier is empty.
sourcepub fn take(self) -> Option<NonEmptyFrontier<H>>
pub fn take(self) -> Option<NonEmptyFrontier<H>>
Consumes this wrapper and returns the underlying Option<NonEmptyFrontier>
sourcepub fn dynamic_memory_usage(&self) -> usize
pub fn dynamic_memory_usage(&self) -> usize
Returns the amount of memory dynamically allocated for ommer values within the frontier.
source§impl<H: Hashable + Clone, const DEPTH: u8> Frontier<H, DEPTH>
impl<H: Hashable + Clone, const DEPTH: u8> Frontier<H, DEPTH>
sourcepub fn append(&mut self, value: H) -> bool
pub fn append(&mut self, value: H) -> bool
Appends a new value to the frontier at the next available slot. Returns true if successful and false if the frontier would exceed the maximum allowed depth.
sourcepub fn root(&self) -> H
pub fn root(&self) -> H
Obtains the current root of this Merkle frontier by hashing against empty nodes up to the maximum height of the pruned tree that the frontier represents.
sourcepub fn witness<F>(
&self,
complement_nodes: F
) -> Result<Option<MerklePath<H, DEPTH>>, Address>
pub fn witness<F>( &self, complement_nodes: F ) -> Result<Option<MerklePath<H, DEPTH>>, Address>
Constructs a MerklePath
to the leaf at the tip of this frontier, given a source of node
values that complement this frontier.
If the complement_nodes
function returns None
when the value is requested at a given
tree address, the address at which the failure occurs will be returned as an error.
Returns Ok(Some(MerklePath))
if successful, Ok(None)
if the frontier is empty,
or an error containing the address of the failure.