Struct incrementalmerkletree::frontier::NonEmptyFrontier
source · pub struct NonEmptyFrontier<H> { /* private fields */ }
Expand description
A NonEmptyFrontier
is a reduced representation of a Merkle tree, containing a single leaf
value, along with the vector of hashes produced by the reduction of previously appended leaf
values that will be required when producing a witness for the current leaf.
Implementations§
source§impl<H> NonEmptyFrontier<H>
impl<H> NonEmptyFrontier<H>
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.
sourcepub fn into_parts(self) -> (Position, H, Vec<H>)
pub fn into_parts(self) -> (Position, H, Vec<H>)
Decomposes the frontier into its constituent parts
source§impl<H: Hashable + Clone> NonEmptyFrontier<H>
impl<H: Hashable + Clone> NonEmptyFrontier<H>
sourcepub fn append(&mut self, leaf: H)
pub fn append(&mut self, leaf: H)
Append a new leaf to the frontier, and recompute ommers by hashing together full subtrees until an empty ommer slot is found.
sourcepub fn root(&self, root_level: Option<Level>) -> H
pub fn root(&self, root_level: Option<Level>) -> H
Generate the root of the Merkle tree by hashing against empty subtree roots.
sourcepub fn witness<F>(
&self,
depth: u8,
complement_nodes: F
) -> Result<Vec<H>, Address>
pub fn witness<F>( &self, depth: u8, complement_nodes: F ) -> Result<Vec<H>, Address>
Constructs a witness for 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.
source§impl<H: Hashable + Clone> NonEmptyFrontier<H>where
Standard: Distribution<H>,
impl<H: Hashable + Clone> NonEmptyFrontier<H>where
Standard: Distribution<H>,
sourcepub fn random_of_size<R: RngCore>(rng: &mut R, tree_size: NonZeroU64) -> Self
pub fn random_of_size<R: RngCore>(rng: &mut R, tree_size: NonZeroU64) -> Self
Generates a random frontier of a Merkle tree having the specified nonzero size.
pub fn random_with_prior_subtree_roots<R: RngCore>( rng: &mut R, tree_size: NonZeroU64, subtree_depth: NonZeroU8 ) -> (Vec<H>, Self)
Trait Implementations§
source§impl<H: Clone> Clone for NonEmptyFrontier<H>
impl<H: Clone> Clone for NonEmptyFrontier<H>
source§fn clone(&self) -> NonEmptyFrontier<H>
fn clone(&self) -> NonEmptyFrontier<H>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<H: Debug> Debug for NonEmptyFrontier<H>
impl<H: Debug> Debug for NonEmptyFrontier<H>
source§impl<H: PartialEq> PartialEq for NonEmptyFrontier<H>
impl<H: PartialEq> PartialEq for NonEmptyFrontier<H>
source§fn eq(&self, other: &NonEmptyFrontier<H>) -> bool
fn eq(&self, other: &NonEmptyFrontier<H>) -> bool
self
and other
values to be equal, and is used
by ==
.