Struct sp_blockchain::TreeRoute
source · pub struct TreeRoute<Block: BlockT> { /* private fields */ }
Expand description
A tree-route from one block to another in the chain.
All blocks prior to the pivot in the deque is the reverse-order unique ancestry of the first block, the block at the pivot index is the common ancestor, and all blocks after the pivot is the ancestry of the second block, in order.
The ancestry sets will include the given blocks, and thus the tree-route is never empty.
Tree route from R1 to E2. Retracted is [R1, R2, R3], Common is C, enacted [E1, E2]
<- R3 <- R2 <- R1
/
C
\-> E1 -> E2
Tree route from C to E2. Retracted empty. Common is C, enacted [E1, E2]
C -> E1 -> E2
Implementations§
source§impl<Block: BlockT> TreeRoute<Block>
impl<Block: BlockT> TreeRoute<Block>
sourcepub fn new(
route: Vec<HashAndNumber<Block>>,
pivot: usize
) -> Result<Self, String>
pub fn new( route: Vec<HashAndNumber<Block>>, pivot: usize ) -> Result<Self, String>
Creates a new TreeRoute
.
To preserve the structure safety invariats it is required that pivot < route.len()
.
sourcepub fn retracted(&self) -> &[HashAndNumber<Block>]
pub fn retracted(&self) -> &[HashAndNumber<Block>]
Get a slice of all retracted blocks in reverse order (towards common ancestor).
sourcepub fn into_retracted(self) -> Vec<HashAndNumber<Block>> ⓘ
pub fn into_retracted(self) -> Vec<HashAndNumber<Block>> ⓘ
Convert into all retracted blocks in reverse order (towards common ancestor).
sourcepub fn common_block(&self) -> &HashAndNumber<Block>
pub fn common_block(&self) -> &HashAndNumber<Block>
Get the common ancestor block. This might be one of the two blocks of the route.
sourcepub fn enacted(&self) -> &[HashAndNumber<Block>]
pub fn enacted(&self) -> &[HashAndNumber<Block>]
Get a slice of enacted blocks (descendents of the common ancestor)
sourcepub fn last(&self) -> Option<&HashAndNumber<Block>>
pub fn last(&self) -> Option<&HashAndNumber<Block>>
Returns the last block.
Trait Implementations§
Auto Trait Implementations§
impl<Block> RefUnwindSafe for TreeRoute<Block>where <Block as Block>::Hash: RefUnwindSafe, <<Block as Block>::Header as Header>::Number: RefUnwindSafe,
impl<Block> Send for TreeRoute<Block>
impl<Block> Sync for TreeRoute<Block>
impl<Block> Unpin for TreeRoute<Block>where <Block as Block>::Hash: Unpin, <<Block as Block>::Header as Header>::Number: Unpin,
impl<Block> UnwindSafe for TreeRoute<Block>where <Block as Block>::Hash: UnwindSafe, <<Block as Block>::Header as Header>::Number: UnwindSafe,
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<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>
§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 more§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,
§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
.