pub struct MerkleMountainRange<T = String>where
T: ToString,{ /* private fields */ }Implementations§
Source§impl<T> MerkleMountainRange<T>where
T: ToString,
impl<T> MerkleMountainRange<T>where
T: ToString,
pub fn new(mmr: Vec<Node>, data: RangeMap<T>, position: Position) -> Self
Sourcepub fn add_vec<D: Digest>(&mut self, objects: Vec<T>)
pub fn add_vec<D: Digest>(&mut self, objects: Vec<T>)
This function adds a vec of leaf nodes to the mmr.
Sourcepub fn add_single<D: Digest>(&mut self, object: T)
pub fn add_single<D: Digest>(&mut self, object: T)
This function adds a new leaf node to the mmr.
Sourcepub fn get_object(&self, hash: &H256) -> Option<&T>
pub fn get_object(&self, hash: &H256) -> Option<&T>
This function returns a reference to the data stored in the mmr It will return none if the hash does not exist
Sourcepub fn get_mut_object(&mut self, hash: &H256) -> Option<&mut T>
pub fn get_mut_object(&mut self, hash: &H256) -> Option<&mut T>
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<H256>
Sourcepub fn get_hash_proof<D: Digest>(&self, hash: &H256) -> Vec<H256>
pub fn get_hash_proof<D: Digest>(&self, hash: &H256) -> Vec<H256>
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
Sourcepub fn get_peak_height(&self) -> usize
pub fn get_peak_height(&self) -> usize
This function returns the peak height of the mmr
Sourcepub fn get_merkle_root<D: Digest>(&self) -> H256
pub fn get_merkle_root<D: Digest>(&self) -> H256
This function will return the single merkle root of the MMR.
Sourcepub fn verify_proof<D: Digest>(&self, hashes: &Vec<H256>) -> bool
pub fn verify_proof<D: Digest>(&self, hashes: &Vec<H256>) -> bool
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
Trait Implementations§
Source§impl<T> Clone for MerkleMountainRange<T>
impl<T> Clone for MerkleMountainRange<T>
Source§fn clone(&self) -> MerkleMountainRange<T>
fn clone(&self) -> MerkleMountainRange<T>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T> Debug for MerkleMountainRange<T>
impl<T> Debug for MerkleMountainRange<T>
Source§impl<T> Default for MerkleMountainRange<T>
impl<T> Default for MerkleMountainRange<T>
Source§fn default() -> MerkleMountainRange<T>
fn default() -> MerkleMountainRange<T>
Source§impl<'de, T> Deserialize<'de> for MerkleMountainRange<T>where
T: ToString + Deserialize<'de>,
impl<'de, T> Deserialize<'de> for MerkleMountainRange<T>where
T: ToString + Deserialize<'de>,
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>,
Source§impl<T> Display for MerkleMountainRange<T>where
T: ToString,
impl<T> Display for MerkleMountainRange<T>where
T: ToString,
Source§impl<T> PartialEq for MerkleMountainRange<T>
impl<T> PartialEq for MerkleMountainRange<T>
Source§fn eq(&self, other: &MerkleMountainRange<T>) -> bool
fn eq(&self, other: &MerkleMountainRange<T>) -> bool
self and other values to be equal, and is used by ==.