Struct sc_client_api::leaves::LeafSet
source · 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§
source§impl<H: PartialEq, N: PartialEq> PartialEq for LeafSet<H, N>
impl<H: PartialEq, N: PartialEq> PartialEq for LeafSet<H, N>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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<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
.