Struct bridgetree::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 new(leaf: H) -> NonEmptyFrontier<H>
pub fn new(leaf: H) -> NonEmptyFrontier<H>
Constructs a new frontier with the specified value at position 0.
sourcepub fn from_parts(
position: Position,
leaf: H,
ommers: Vec<H, Global>
) -> Result<NonEmptyFrontier<H>, FrontierError>
pub fn from_parts( position: Position, leaf: H, ommers: Vec<H, Global> ) -> Result<NonEmptyFrontier<H>, FrontierError>
Constructs a new frontier from its constituent parts.
sourcepub fn into_parts(self) -> (Position, H, Vec<H, Global>)
pub fn into_parts(self) -> (Position, H, Vec<H, Global>)
Decomposes the frontier into its constituent parts
source§impl<H> NonEmptyFrontier<H>where
H: Hashable + Clone,
impl<H> NonEmptyFrontier<H>where H: Hashable + Clone,
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, Global>, Address>where
F: Fn(Address) -> Option<H>,
pub fn witness<F>( &self, depth: u8, complement_nodes: F ) -> Result<Vec<H, Global>, Address>where F: Fn(Address) -> Option<H>,
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.
Trait Implementations§
source§impl<H> Clone for NonEmptyFrontier<H>where
H: Clone,
impl<H> Clone for NonEmptyFrontier<H>where H: Clone,
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 for NonEmptyFrontier<H>where
H: Debug,
impl<H> Debug for NonEmptyFrontier<H>where H: Debug,
source§impl<H> PartialEq<NonEmptyFrontier<H>> for NonEmptyFrontier<H>where
H: PartialEq<H>,
impl<H> PartialEq<NonEmptyFrontier<H>> for NonEmptyFrontier<H>where H: PartialEq<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 ==.