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
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
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 Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere T: Bounded, S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.