[][src]Struct indy_data_types::merkle_tree::MerkleTree

pub struct MerkleTree {
    pub root: Tree,
    pub height: usize,
    pub count: usize,
    pub nodes_count: usize,
}

A Merkle tree is a binary tree, with values of type T at the leafs, and where every internal node holds the hash of the concatenation of the hashes of its children nodes.

Fields

root: Tree

The root of the inner binary tree

height: usize

The height of the tree

count: usize

The number of leaf nodes in the tree

nodes_count: usize

The number of nodes in the tree

Implementations

impl MerkleTree[src]

pub fn from_vec(values: Vec<Vec<u8>>) -> Result<Self, ValidationError>[src]

Constructs a Merkle Tree from a vector of data blocks. Returns None if values is empty.

pub fn root_hash(&self) -> &Vec<u8>[src]

Returns the root hash of Merkle tree

pub fn root_hash_hex(&self) -> String[src]

Returns the hex root hash of Merkle tree

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

Returns the height of Merkle tree

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

Returns the number of leaves in the Merkle tree

pub fn is_empty(&self) -> bool[src]

Returns whether the Merkle tree is empty or not

pub fn gen_proof(
    &self,
    value: Vec<u8>
) -> Result<Option<Proof>, ValidationError>
[src]

Generate an inclusion proof for the given value. Returns None if the given value is not found in the tree.

pub fn iter(&self) -> LeavesIterator[src]

Creates an Iterator over the values contained in this Merkle tree.

impl MerkleTree[src]

pub fn find_hash<'a>(
    from: &'a Tree,
    required_hash: &Vec<u8>
) -> Option<&'a Tree>
[src]

pub fn consistency_proof(
    &self,
    new_root_hash: &Vec<u8>,
    new_size: usize,
    proof: &Vec<Vec<u8>>
) -> Result<bool, ValidationError>
[src]

pub fn append(&mut self, node: Vec<u8>) -> Result<(), ValidationError>[src]

Trait Implementations

impl Clone for MerkleTree[src]

impl Debug for MerkleTree[src]

impl Default for MerkleTree[src]

impl<'de> Deserialize<'de> for MerkleTree[src]

impl IntoIterator for MerkleTree[src]

type Item = Vec<u8>

The type of the elements being iterated over.

type IntoIter = LeavesIntoIterator

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates a consuming iterator, that is, one that moves each value out of the Merkle tree. The tree cannot be used after calling this.

impl<'a> IntoIterator for &'a MerkleTree[src]

type Item = &'a Vec<u8>

The type of the elements being iterated over.

type IntoIter = LeavesIterator<'a>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates a borrowing Iterator over the values contained in this Merkle tree.

impl Serialize for MerkleTree[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.