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 vector 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 invariants 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 (descendants 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> Freeze for TreeRoute<Block>
impl<Block> RefUnwindSafe for TreeRoute<Block>where
<<Block as Block>::Header as Header>::Number: RefUnwindSafe,
<Block as Block>::Hash: RefUnwindSafe,
impl<Block> Send for TreeRoute<Block>
impl<Block> Sync for TreeRoute<Block>
impl<Block> Unpin for TreeRoute<Block>
impl<Block> UnwindSafe for TreeRoute<Block>
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<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> 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
.