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>where
H: Clone + PartialEq + Decode + Encode,
N: Debug + Clone + AtLeast32Bit + Decode + Encode,
impl<H, N> LeafSet<H, N>where H: Clone + PartialEq + Decode + Encode, N: Debug + Clone + AtLeast32Bit + Decode + Encode,
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 finalize_height(&mut self, number: N) -> FinalizationOutcome<H, N>
pub fn finalize_height(&mut self, number: N) -> FinalizationOutcome<H, N>
Note a block height finalized, displacing all leaves with number less than the finalized block’s.
Although it would be more technically correct to also prune out leaves at the same number as the finalized block, but with different hashes, the current behavior is simpler and our assumptions about how finalization works means that those leaves will be pruned soon afterwards anyway.
sourcepub fn displaced_by_finalize_height(
&self,
number: N
) -> FinalizationOutcome<H, N>
pub fn displaced_by_finalize_height( &self, number: N ) -> FinalizationOutcome<H, N>
The same as Self::finalize_height
, but it only simulates the operation.
This means that no changes are done.
Returns the leaves that would be displaced by finalizing the given block.
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<LeafSet<H, N>> for LeafSet<H, N>
impl<H: PartialEq, N: PartialEq> PartialEq<LeafSet<H, N>> for LeafSet<H, N>
impl<H: Eq, N: Eq> Eq for LeafSet<H, N>
impl<H, N> StructuralEq for LeafSet<H, N>
impl<H, N> StructuralPartialEq for LeafSet<H, N>
Auto Trait Implementations§
impl<H, N> RefUnwindSafe for LeafSet<H, N>where H: RefUnwindSafe, N: RefUnwindSafe,
impl<H, N> Send for LeafSet<H, N>where H: Send, N: Send,
impl<H, N> Sync for LeafSet<H, N>where H: Sync, N: Sync,
impl<H, N> Unpin for LeafSet<H, N>
impl<H, N> UnwindSafe for LeafSet<H, N>where H: RefUnwindSafe, N: RefUnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
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, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere Self: UniqueSaturatedFrom<T>,
§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
.§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.