Struct MerkleMountainRange

Source
pub struct MerkleMountainRange<T = String>
where T: ToString,
{ /* private fields */ }

Implementations§

Source§

impl<T> MerkleMountainRange<T>
where T: ToString,

Source

pub fn new(mmr: Vec<Node>, data: RangeMap<T>, position: Position) -> Self

Source

pub fn add_vec<D: Digest>(&mut self, objects: Vec<T>)

This function adds a vec of leaf nodes to the mmr.

Source

pub fn add_single<D: Digest>(&mut self, object: T)

This function adds a new leaf node to the mmr.

Source

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

Source

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

Source

pub fn get_hash(&self, index: usize) -> Option<H256>

Source

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

Source

pub fn get_peak_height(&self) -> usize

This function returns the peak height of the mmr

Source

pub fn get_merkle_root<D: Digest>(&self) -> H256

This function will return the single merkle root of the MMR.

Source

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>
where T: ToString + Clone,

Source§

fn clone(&self) -> MerkleMountainRange<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for MerkleMountainRange<T>
where T: ToString + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for MerkleMountainRange<T>
where T: ToString + Default,

Source§

fn default() -> MerkleMountainRange<T>

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for MerkleMountainRange<T>
where T: ToString,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hashable for MerkleMountainRange

Source§

fn hash(&self) -> H256

Source§

impl<T> PartialEq for MerkleMountainRange<T>
where T: ToString + PartialEq,

Source§

fn eq(&self, other: &MerkleMountainRange<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for MerkleMountainRange<T>
where T: ToString + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T> Eq for MerkleMountainRange<T>
where T: ToString + Eq,

Source§

impl<T> StructuralPartialEq for MerkleMountainRange<T>
where T: ToString,

Auto Trait Implementations§

§

impl<T> Freeze for MerkleMountainRange<T>

§

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<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

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