Struct indy_data_types::merkle_tree::MerkleTree
source · pub struct MerkleTree {
pub root: Tree,
pub height: usize,
pub count: usize,
pub nodes_count: usize,
}
Expand description
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§
source§impl MerkleTree
impl MerkleTree
sourcepub fn from_vec(values: Vec<Vec<u8>>) -> Result<Self, ValidationError>
pub fn from_vec(values: Vec<Vec<u8>>) -> Result<Self, ValidationError>
Constructs a Merkle Tree from a vector of data blocks.
Returns None
if values
is empty.
sourcepub fn root_hash_hex(&self) -> String
pub fn root_hash_hex(&self) -> String
Returns the hex root hash of Merkle tree
source§impl MerkleTree
impl MerkleTree
pub fn find_hash<'a>( 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<u8>] ) -> Result<bool, ValidationError>
pub fn append(&mut self, node: Vec<u8>) -> Result<(), ValidationError>
pub fn check_inclusion_proof( root_hash: &[u8], leaf_value: &Vec<u8>, path: &[Positioned<Vec<u8>>] ) -> Result<bool, ValidationError>
Trait Implementations§
source§impl Clone for MerkleTree
impl Clone for MerkleTree
source§fn clone(&self) -> MerkleTree
fn clone(&self) -> MerkleTree
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MerkleTree
impl Debug for MerkleTree
source§impl Default for MerkleTree
impl Default for MerkleTree
source§impl<'de> Deserialize<'de> for MerkleTree
impl<'de> Deserialize<'de> for MerkleTree
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a> IntoIterator for &'a MerkleTree
impl<'a> IntoIterator for &'a MerkleTree
source§impl IntoIterator for MerkleTree
impl IntoIterator for MerkleTree
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more