Struct polkadot_ckb_merkle_mountain_range::MMR
source · pub struct MMR<T, M, S> { /* private fields */ }
Implementations§
source§impl<T: Clone + PartialEq, M: Merge<Item = T>, S: MMRStoreReadOps<T>> MMR<T, M, S>
impl<T: Clone + PartialEq, M: Merge<Item = T>, S: MMRStoreReadOps<T>> MMR<T, M, S>
pub fn push(&mut self, elem: T) -> Result<u64>
sourcepub fn get_ancestor_peaks_and_root(
&self,
prev_mmr_size: u64
) -> Result<(Vec<T>, T)>
pub fn get_ancestor_peaks_and_root( &self, prev_mmr_size: u64 ) -> Result<(Vec<T>, T)>
get_ancestor_root
sourcepub fn gen_proof(&self, pos_list: Vec<u64>) -> Result<MerkleProof<T, M>>
pub fn gen_proof(&self, pos_list: Vec<u64>) -> Result<MerkleProof<T, M>>
Generate merkle proof for positions
- sort positions
- push merkle proof to proof by peak from left to right
- push bagged right hand side root
sourcepub fn gen_node_proof(
&self,
pos_list: Vec<u64>
) -> Result<NodeMerkleProof<T, M>>
pub fn gen_node_proof( &self, pos_list: Vec<u64> ) -> Result<NodeMerkleProof<T, M>>
Generate node merkle proof for positions
- sort positions
- push merkle proof to proof by peak from left to right
- push bagged right hand side root
sourcepub fn gen_ancestry_proof(
&self,
prev_mmr_size: u64
) -> Result<AncestryProof<T, M>>
pub fn gen_ancestry_proof( &self, prev_mmr_size: u64 ) -> Result<AncestryProof<T, M>>
Generate proof that prior merkle root r’ is an ancestor of current merkle proof r
- calculate positions of peaks of old root r’ given mmr size n
- generate membership proof of peaks in root r
- calculate r’ from peaks(n)
- return (mmr root r’, peak hashes, membership proof of peaks(n) in r)
Auto Trait Implementations§
impl<T, M, S> Freeze for MMR<T, M, S>where
S: Freeze,
impl<T, M, S> RefUnwindSafe for MMR<T, M, S>
impl<T, M, S> Send for MMR<T, M, S>
impl<T, M, S> Sync for MMR<T, M, S>
impl<T, M, S> Unpin for MMR<T, M, S>
impl<T, M, S> UnwindSafe for MMR<T, M, S>
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more