pub struct LeafSet<H, N> { /* private fields */ }Expand description
list of leaf hashes ordered by number (descending). stored in memory for fast access. this allows very fast checking and modification of active leaves.
Implementations§
Source§impl<H, N> LeafSet<H, N>
impl<H, N> LeafSet<H, N>
Sourcepub fn read_from_db(
db: &dyn Database<H256>,
column: u32,
prefix: &[u8],
) -> Result<Self>
pub fn read_from_db( db: &dyn Database<H256>, column: u32, prefix: &[u8], ) -> Result<Self>
Read the leaf list from the DB, using given prefix for keys.
Sourcepub fn import(
&mut self,
hash: H,
number: N,
parent_hash: H,
) -> ImportOutcome<H, N>
pub fn import( &mut self, hash: H, number: N, parent_hash: H, ) -> ImportOutcome<H, N>
Update the leaf list on import.
Sourcepub fn remove(
&mut self,
hash: H,
number: N,
parent_hash: Option<H>,
) -> Option<RemoveOutcome<H, N>>
pub fn remove( &mut self, hash: H, number: N, parent_hash: Option<H>, ) -> Option<RemoveOutcome<H, N>>
Update the leaf list on removal.
Note that the leaves set structure doesn’t have the information to decide if the
leaf we’re removing is the last children of the parent. Follows that this method requires
the caller to check this condition and optionally pass the parent_hash if hash is
its last child.
Returns None if no modifications are applied.
Sourcepub fn remove_displaced_leaves<I>(
&mut self,
displaced_leaves: FinalizationOutcome<I, H, N>,
)
pub fn remove_displaced_leaves<I>( &mut self, displaced_leaves: FinalizationOutcome<I, H, N>, )
Remove all leaves displaced by the last block finalization.
Sourcepub fn undo(&mut self) -> Undo<'_, H, N>
pub fn undo(&mut self) -> Undo<'_, H, N>
Undo all pending operations.
This returns an Undo struct, where any
Displaced objects that have returned by previous method calls
should be passed to via the appropriate methods. Otherwise,
the on-disk state may get out of sync with in-memory state.
Sourcepub fn revert(&mut self, best_hash: H, best_number: N)
pub fn revert(&mut self, best_hash: H, best_number: N)
Revert to the given block height by dropping all leaves in the leaf set with a block number higher than the target.
Sourcepub fn hashes(&self) -> Vec<H>
pub fn hashes(&self) -> Vec<H>
returns an iterator over all hashes in the leaf set ordered by their block number descending.
Sourcepub fn prepare_transaction(
&mut self,
tx: &mut Transaction<H256>,
column: u32,
prefix: &[u8],
)
pub fn prepare_transaction( &mut self, tx: &mut Transaction<H256>, column: u32, prefix: &[u8], )
Write the leaf list to the database transaction.
Sourcepub fn highest_leaf(&self) -> Option<(N, &[H])>
pub fn highest_leaf(&self) -> Option<(N, &[H])>
Returns the highest leaf and all hashes associated to it.
Trait Implementations§
impl<H: Eq, N: Eq> Eq for LeafSet<H, N>
impl<H, N> StructuralPartialEq for LeafSet<H, N>
Auto Trait Implementations§
impl<H, N> Freeze for LeafSet<H, N>
impl<H, N> RefUnwindSafe for LeafSet<H, N>where
N: RefUnwindSafe,
H: RefUnwindSafe,
impl<H, N> Send for LeafSet<H, N>
impl<H, N> Sync for LeafSet<H, N>
impl<H, N> Unpin for LeafSet<H, N>
impl<H, N> UnwindSafe for LeafSet<H, N>where
N: RefUnwindSafe,
H: RefUnwindSafe,
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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
impl<Src, Dest> IntoTuple<Dest> for Srcwhere
Dest: FromTuple<Src>,
fn into_tuple(self) -> Dest
Source§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
T. Read moreSource§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T.