Struct grin_core::core::pmmr::ReadonlyPMMR
source · pub struct ReadonlyPMMR<'a, T, B>{ /* private fields */ }
Expand description
Readonly view of a PMMR.
Implementations§
source§impl<'a, T, B> ReadonlyPMMR<'a, T, B>
impl<'a, T, B> ReadonlyPMMR<'a, T, B>
sourcepub fn new(backend: &'a B) -> ReadonlyPMMR<'_, T, B>
pub fn new(backend: &'a B) -> ReadonlyPMMR<'_, T, B>
Build a new readonly PMMR.
sourcepub fn at(backend: &'a B, size: u64) -> ReadonlyPMMR<'_, T, B>
pub fn at(backend: &'a B, size: u64) -> ReadonlyPMMR<'_, T, B>
Build a new readonly PMMR pre-initialized to size with the provided backend.
sourcepub fn elements_from_pmmr_index(
&self,
pmmr_index1: u64,
max_count: u64,
max_pmmr_pos1: Option<u64>
) -> (u64, Vec<T::E>)
pub fn elements_from_pmmr_index( &self, pmmr_index1: u64, max_count: u64, max_pmmr_pos1: Option<u64> ) -> (u64, Vec<T::E>)
Helper function which returns un-pruned nodes from the insertion index forward returns last pmmr index returned along with data
sourcepub fn get_last_n_insertions(&self, n: u64) -> Vec<(Hash, T::E)>
pub fn get_last_n_insertions(&self, n: u64) -> Vec<(Hash, T::E)>
Helper function to get the last N nodes inserted, i.e. the last n nodes along the bottom of the tree. May return less than n items if the MMR has been pruned/compacted. NOTE This should just iterate over insertion indices to avoid the repeated calls to bintree_rightmost!
Trait Implementations§
source§impl<'a, T, B> ReadablePMMR for ReadonlyPMMR<'a, T, B>
impl<'a, T, B> ReadablePMMR for ReadonlyPMMR<'a, T, B>
source§fn get_hash(&self, pos0: u64) -> Option<Hash>
fn get_hash(&self, pos0: u64) -> Option<Hash>
Get the hash at provided position in the MMR.
NOTE all positions are 0-based, so a size n MMR has nodes in positions 0 through n-1
just like a Rust Range 0..n
source§fn get_data(&self, pos0: u64) -> Option<Self::Item>
fn get_data(&self, pos0: u64) -> Option<Self::Item>
Get the data element at provided position in the MMR.
source§fn get_from_file(&self, pos0: u64) -> Option<Hash>
fn get_from_file(&self, pos0: u64) -> Option<Hash>
Get the hash from the underlying MMR file (ignores the remove log).
source§fn get_peak_from_file(&self, pos0: u64) -> Option<Hash>
fn get_peak_from_file(&self, pos0: u64) -> Option<Hash>
Get the hash for the provided peak pos.
Optimized for reading peak hashes rather than arbitrary pos hashes.
Peaks can be assumed to not be compacted.
source§fn get_data_from_file(&self, pos0: u64) -> Option<Self::Item>
fn get_data_from_file(&self, pos0: u64) -> Option<Self::Item>
Get the data element at provided position in the MMR (ignores the remove log).
source§fn unpruned_size(&self) -> u64
fn unpruned_size(&self) -> u64
Total size of the tree, including intermediary nodes and ignoring any pruning.
source§fn leaf_pos_iter(&self) -> Box<dyn Iterator<Item = u64> + '_>
fn leaf_pos_iter(&self) -> Box<dyn Iterator<Item = u64> + '_>
Iterator over current (unpruned, unremoved) leaf positions.
source§fn leaf_idx_iter(&self, from_idx: u64) -> Box<dyn Iterator<Item = u64> + '_>
fn leaf_idx_iter(&self, from_idx: u64) -> Box<dyn Iterator<Item = u64> + '_>
Iterator over current (unpruned, unremoved) leaf insertion indices.
source§fn n_unpruned_leaves(&self) -> u64
fn n_unpruned_leaves(&self) -> u64
Number of leaves in the MMR
source§fn n_unpruned_leaves_to_index(&self, to_index: u64) -> u64
fn n_unpruned_leaves_to_index(&self, to_index: u64) -> u64
Number of leaves in the MMR up to index
source§fn bag_the_rhs(&self, peak_pos0: u64) -> Option<Hash>
fn bag_the_rhs(&self, peak_pos0: u64) -> Option<Hash>
Takes a single peak position and hashes together
all the peaks to the right of this peak (if any).
If this return a hash then this is our peaks sibling.
If none then the sibling of our peak is the peak to the left.
source§fn peak_path(&self, peak_pos0: u64) -> Vec<Hash>
fn peak_path(&self, peak_pos0: u64) -> Vec<Hash>
Hashes of the peaks excluding
peak_pos
, where the rhs is bagged togethersource§fn root(&self) -> Result<Hash, String>
fn root(&self) -> Result<Hash, String>
Computes the root of the MMR. Find all the peaks in the current
tree and “bags” them to get a single peak.
source§fn merkle_proof(&self, pos0: u64) -> Result<MerkleProof, String>
fn merkle_proof(&self, pos0: u64) -> Result<MerkleProof, String>
Build a Merkle proof for the element at the given position.
Auto Trait Implementations§
impl<'a, T, B> Freeze for ReadonlyPMMR<'a, T, B>
impl<'a, T, B> RefUnwindSafe for ReadonlyPMMR<'a, T, B>where
B: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, B> Send for ReadonlyPMMR<'a, T, B>
impl<'a, T, B> Sync for ReadonlyPMMR<'a, T, B>
impl<'a, T, B> Unpin for ReadonlyPMMR<'a, T, B>where
T: Unpin,
impl<'a, T, B> UnwindSafe for ReadonlyPMMR<'a, T, B>where
B: RefUnwindSafe,
T: UnwindSafe,
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