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>

source

pub fn new(leaf: H) -> Self

Constructs a new frontier with the specified value at position 0.

source

pub fn from_parts( position: Position, leaf: H, ommers: Vec<H> ) -> Result<Self, FrontierError>

Constructs a new frontier from its constituent parts.

source

pub fn into_parts(self) -> (Position, H, Vec<H>)

Decomposes the frontier into its constituent parts

source

pub fn position(&self) -> Position

Returns the position of the most recently appended leaf.

source

pub fn leaf(&self) -> &H

Returns the leaf most recently appended to the frontier.

source

pub fn ommers(&self) -> &[H]

Returns the list of past hashes required to construct a witness for the leaf most recently appended to the frontier.

source§

impl<H: Hashable + Clone> NonEmptyFrontier<H>

source

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.

source

pub fn root(&self, root_level: Option<Level>) -> H

Generate the root of the Merkle tree by hashing against empty subtree roots.

source

pub fn witness<F>( &self, depth: u8, complement_nodes: F ) -> Result<Vec<H>, 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.

source§

impl<H: Hashable + Clone> NonEmptyFrontier<H>

source

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.

source

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>

source§

fn clone(&self) -> NonEmptyFrontier<H>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<H: Debug> Debug for NonEmptyFrontier<H>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<H: PartialEq> PartialEq for NonEmptyFrontier<H>

source§

fn eq(&self, other: &NonEmptyFrontier<H>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<H, const DEPTH: u8> TryFrom<NonEmptyFrontier<H>> for Frontier<H, DEPTH>

§

type Error = FrontierError

The type returned in the event of a conversion error.
source§

fn try_from(f: NonEmptyFrontier<H>) -> Result<Self, FrontierError>

Performs the conversion.
source§

impl<H: Eq> Eq for NonEmptyFrontier<H>

source§

impl<H> StructuralPartialEq for NonEmptyFrontier<H>

Auto Trait Implementations§

§

impl<H> Freeze for NonEmptyFrontier<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for NonEmptyFrontier<H>
where H: RefUnwindSafe,

§

impl<H> Send for NonEmptyFrontier<H>
where H: Send,

§

impl<H> Sync for NonEmptyFrontier<H>
where H: Sync,

§

impl<H> Unpin for NonEmptyFrontier<H>
where H: Unpin,

§

impl<H> UnwindSafe for NonEmptyFrontier<H>
where H: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V