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) -> NonEmptyFrontier<H>

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

source

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

Constructs a new frontier from its constituent parts.

source

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

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> NonEmptyFrontier<H>where H: Hashable + Clone,

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, 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,

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 for NonEmptyFrontier<H>where H: Debug,

source§

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

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

impl<H> PartialEq<NonEmptyFrontier<H>> for NonEmptyFrontier<H>where H: PartialEq<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<Frontier<H, DEPTH>, FrontierError>

Performs the conversion.
source§

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

source§

impl<H> StructuralEq for NonEmptyFrontier<H>

source§

impl<H> StructuralPartialEq for NonEmptyFrontier<H>

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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 Twhere 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.