[][src]Struct merklemountainrange::merklemountainrange::MerkleMountainRange

pub struct MerkleMountainRange<T, D> where
    T: Hashable,
    D: Digest
{ /* fields omitted */ }

Methods

impl<T, D> MerkleMountainRange<T, D> where
    T: Hashable,
    D: Digest
[src]

pub fn new() -> MerkleMountainRange<T, D>[src]

This function creates a new empty Merkle Mountain Range

pub fn get_object(&self, hash: &ObjectHash) -> Option<&T>[src]

This function returns a reference to the data stored in the mmr It will return none if the hash does not exist

pub fn get_mut_object(&mut self, hash: &ObjectHash) -> Option<&mut T>[src]

This function returns a mut reference to the data stored in the MMR It will return none if the hash does not exist

pub fn get_hash(&self, index: usize) -> Option<ObjectHash>[src]

pub fn get_hash_proof(&self, hash: &ObjectHash) -> Vec<ObjectHash>[src]

This function returns the hash proof tree of a given hash. If the given hash is not in the tree, the vec will be empty. The Vec will be created in form of the Lchild-Rchild-parent(Lchild)-Rchild-parent-.. This pattern will be repeated until the parent is the root of the MMR

pub fn verify_proof(&self, hashes: &Vec<ObjectHash>) -> bool[src]

This function will verify the provided proof. Internally it uses the get_hash_proof function to construct a similar proof. This function will return true if the proof is valid If the order does not match Lchild-Rchild-parent(Lchild)-Rchild-parent-.. the validation will fail This function will only succeed if the given hash is of height 0

pub fn get_peak_height(&self) -> usize[src]

This function returns the peak height of the mmr

pub fn get_merkle_root(&self) -> ObjectHash[src]

This function will return the single merkle root of the MMR.

pub fn add_vec(&mut self, objects: Vec<T>)[src]

This function adds a vec of leaf nodes to the mmr.

pub fn add_single(&mut self, object: T)[src]

This function adds a new leaf node to the mmr.

Auto Trait Implementations

impl<T, D> Send for MerkleMountainRange<T, D> where
    D: Send,
    T: Send

impl<T, D> Sync for MerkleMountainRange<T, D> where
    D: Sync,
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same for T

type Output = T

Should always be Self