pub struct MerkleAccumulator<R, H> { /* private fields */ }
Expand description

In this live Merkle Accumulator algorithms.

Implementations§

source§

impl<R, H> MerkleAccumulator<R, H>where R: HashReader, H: CryptoHasher,

source

pub fn append( reader: &R, num_existing_leaves: LeafCount, new_leaves: &[HashValue] ) -> Result<(HashValue, Vec<(Position, HashValue)>)>

Given an existing Merkle Accumulator (represented by num_existing_leaves and a reader that is able to fetch all existing frozen nodes), and a list of leaves to be appended, returns the result root hash and new nodes to be frozen.

source

pub fn get_proof( reader: &R, num_leaves: LeafCount, leaf_index: u64 ) -> Result<AccumulatorProof<H>>

Get proof of inclusion of the leaf at leaf_index in this Merkle Accumulator of num_leaves leaves in total. Siblings are read via reader (or generated dynamically if they are non-frozen).

See [diem_types::proof::AccumulatorProof] for proof format.

source

pub fn get_consistency_proof( reader: &R, full_acc_leaves: LeafCount, sub_acc_leaves: LeafCount ) -> Result<AccumulatorConsistencyProof>

Gets a proof that shows the full accumulator is consistent with a smaller accumulator.

See [diem_types::proof::AccumulatorConsistencyProof] for proof format.

source

pub fn get_range_proof( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option<u64>, num_leaves: LeafCount ) -> Result<AccumulatorRangeProof<H>>

Gets a proof that shows a range of leaves are part of the accumulator.

See [diem_types::proof::AccumulatorRangeProof] for proof format.

source

pub fn get_range_proof_positions( reader: &R, full_acc_leaves: LeafCount, first_leaf_index: Option<u64>, num_leaves: LeafCount ) -> Result<(Vec<Position>, Vec<Position>)>

See get_range_proof. This is the version of it that returns Positions only.

source

pub fn get_frozen_subtree_hashes( reader: &R, num_leaves: LeafCount ) -> Result<Vec<HashValue>>

From left to right, gets frozen subtree root hashes of the accumulator. For example, if the accumulator has 5 leaves, x and e are returned.

                root
               /    \
             /        \
           /            \
          x              o
        /   \           / \
       /     \         /   \
      o       o       o     placeholder
     / \     / \     / \
    a   b   c   d   e   placeholder
source

pub fn get_root_hash(reader: &R, num_leaves: LeafCount) -> Result<HashValue>

Get root hash at a specific version (hence num_leaves).

Auto Trait Implementations§

§

impl<R, H> RefUnwindSafe for MerkleAccumulator<R, H>where H: RefUnwindSafe, R: RefUnwindSafe,

§

impl<R, H> Send for MerkleAccumulator<R, H>where H: Send, R: Send,

§

impl<R, H> Sync for MerkleAccumulator<R, H>where H: Sync, R: Sync,

§

impl<R, H> Unpin for MerkleAccumulator<R, H>where H: Unpin, R: Unpin,

§

impl<R, H> UnwindSafe for MerkleAccumulator<R, H>where H: UnwindSafe, R: 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V