[−][src]Struct indy_data_types::merkle_tree::MerkleTree
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]
&self,
value: Vec<u8>
) -> Result<Option<Proof>, ValidationError>
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]
from: &'a Tree,
required_hash: &Vec<u8>
) -> Option<&'a Tree>
pub fn consistency_proof(
&self,
new_root_hash: &Vec<u8>,
new_size: usize,
proof: &Vec<Vec<u8>>
) -> Result<bool, ValidationError>
[src]
&self,
new_root_hash: &Vec<u8>,
new_size: usize,
proof: &Vec<Vec<u8>>
) -> Result<bool, ValidationError>
pub fn append(&mut self, node: Vec<u8>) -> Result<(), ValidationError>
[src]
Trait Implementations
impl Clone for MerkleTree
[src]
fn clone(&self) -> MerkleTree
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for MerkleTree
[src]
impl Default for MerkleTree
[src]
impl<'de> Deserialize<'de> for MerkleTree
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnwindSafe for MerkleTree
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,