Struct grin_store::leaf_set::LeafSet

source ·
pub struct LeafSet { /* private fields */ }
Expand description

Compact (roaring) bitmap representing the set of positions of leaves that are currently unpruned in the MMR.

Implementations§

source§

impl LeafSet

source

pub fn open<P: AsRef<Path>>(path: P) -> Result<LeafSet>

Open the remove log file. The content of the file will be read in memory for fast checking.

source

pub fn copy_snapshot<P: AsRef<Path>>(path: P, cp_path: P) -> Result<()>

Copies a snapshot of the utxo file into the primary utxo file.

source

pub fn removed_pre_cutoff( &self, cutoff_pos: u64, rewind_rm_pos: &Bitmap, prune_list: &PruneList ) -> Bitmap

Calculate the set of pruned positions up to and including the cutoff_pos. Uses both the leaf_set and the prune_list to determine prunedness.

source

pub fn rewind(&mut self, cutoff_pos: u64, rewind_rm_pos: &Bitmap)

Rewinds the leaf_set back to a previous state. Removes all pos after the cutoff. Adds back all pos in rewind_rm_pos.

source

pub fn add(&mut self, pos0: u64)

Append a new position to the leaf_set.

source

pub fn remove(&mut self, pos0: u64)

Remove the provided position from the leaf_set.

source

pub fn snapshot(&self, header: &BlockHeader) -> Result<()>

Saves the utxo file tagged with block hash as filename suffix. Needed during fast-sync as the receiving node cannot rewind after receiving the txhashset zip file.

source

pub fn flush(&mut self) -> Result<()>

Flush the leaf_set to file.

source

pub fn discard(&mut self)

Discard any pending changes.

source

pub fn includes(&self, pos0: u64) -> bool

Whether the leaf_set includes the provided position.

source

pub fn len(&self) -> usize

Number of positions stored in the leaf_set.

source

pub fn n_unpruned_leaves_to_index(&self, to_index: u64) -> u64

Number of positions up to index n in the leaf set

source

pub fn is_empty(&self) -> bool

Is the leaf_set empty.

source

pub fn iter(&self) -> impl Iterator<Item = u64> + '_

Iterator over positionns in the leaf_set (all leaf positions).

Auto Trait Implementations§

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> 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> SafeBorrow<T> for T
where T: ?Sized,

source§

fn borrow_replacement(ptr: &T) -> &T

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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<T> UnsafeAny for T
where T: Any,