Struct algae_mmr::MerkleMountainRange
source · pub struct MerkleMountainRange<T: Hashable> { /* private fields */ }Implementations§
source§impl<T: Hashable> MerkleMountainRange<T>
impl<T: Hashable> MerkleMountainRange<T>
pub fn new(mmr: Vec<MerkleNode>, data: RangeMap<T>, position: Position) -> Self
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 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
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 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.
Trait Implementations§
source§impl<T: Clone + Hashable> Clone for MerkleMountainRange<T>
impl<T: Clone + Hashable> Clone for MerkleMountainRange<T>
source§fn clone(&self) -> MerkleMountainRange<T>
fn clone(&self) -> MerkleMountainRange<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<T: Debug + Hashable> Debug for MerkleMountainRange<T>
impl<T: Debug + Hashable> Debug for MerkleMountainRange<T>
source§impl<T: Default + Hashable> Default for MerkleMountainRange<T>
impl<T: Default + Hashable> Default for MerkleMountainRange<T>
source§fn default() -> MerkleMountainRange<T>
fn default() -> MerkleMountainRange<T>
source§impl<'de, T> Deserialize<'de> for MerkleMountainRange<T>where
T: Deserialize<'de> + Hashable,
impl<'de, T> Deserialize<'de> for MerkleMountainRange<T>where
T: Deserialize<'de> + Hashable,
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: Hashable + Serialize> Display for MerkleMountainRange<T>
impl<T: Hashable + Serialize> Display for MerkleMountainRange<T>
source§impl<T: Hashable + ToString + Serialize> Hashable for MerkleMountainRange<T>
impl<T: Hashable + ToString + Serialize> Hashable for MerkleMountainRange<T>
source§impl<T: PartialEq + Hashable> PartialEq<MerkleMountainRange<T>> for MerkleMountainRange<T>
impl<T: PartialEq + Hashable> PartialEq<MerkleMountainRange<T>> 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 ==.source§impl<T> Serialize for MerkleMountainRange<T>where
T: Serialize + Hashable,
impl<T> Serialize for MerkleMountainRange<T>where
T: Serialize + Hashable,
impl<T: Eq + Hashable> Eq for MerkleMountainRange<T>
impl<T: Hashable> StructuralEq for MerkleMountainRange<T>
impl<T: Hashable> StructuralPartialEq for MerkleMountainRange<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for MerkleMountainRange<T>where
T: RefUnwindSafe,
impl<T> Send for MerkleMountainRange<T>where
T: Send,
impl<T> Sync for MerkleMountainRange<T>where
T: Sync,
impl<T> Unpin for MerkleMountainRange<T>where
T: Unpin,
impl<T> UnwindSafe for MerkleMountainRange<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.