NonEmptyFrontier

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

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>, ) -> Result<NonEmptyFrontier<H>, 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> 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>, 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 duplicate 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 for NonEmptyFrontier<H>
where H: PartialEq,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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>

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

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

Source§

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.