Struct phron_finality::sync::forest::Forest
source · pub struct Forest<I, J>where
I: PeerId,
J: Justification,{
vertices: HashMap<BlockId, VertexWithChildren<I, J>>,
highest_justified: BlockId,
justified_blocks: HashMap<BlockNumber, BlockId>,
imported_leaves: HashSet<BlockId>,
favourite: BlockId,
root_id: BlockId,
root_children: HashSet<BlockId>,
compost_bin: HashSet<BlockId>,
}
Fields§
§vertices: HashMap<BlockId, VertexWithChildren<I, J>>
§highest_justified: BlockId
§justified_blocks: HashMap<BlockNumber, BlockId>
§imported_leaves: HashSet<BlockId>
§favourite: BlockId
§root_id: BlockId
§root_children: HashSet<BlockId>
§compost_bin: HashSet<BlockId>
Implementations§
source§impl<I, J> Forest<I, J>where
I: PeerId,
J: Justification,
impl<I, J> Forest<I, J>where
I: PeerId,
J: Justification,
pub fn new<B, CS>(
chain_status: &CS
) -> Result<Self, InitializationError<B, J, CS>>where
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
CS: ChainStatus<B, J>,
fn special_state(&self, id: &BlockId) -> Option<SpecialState>
fn get_mut(&mut self, id: &BlockId) -> VertexHandleMut<'_, I, J>
fn get(&self, id: &BlockId) -> VertexHandle<'_, I, J>
fn connect_parent(&mut self, id: &BlockId)
fn set_required(&mut self, id: &BlockId)
fn set_explicitly_required(&mut self, id: &BlockId) -> bool
fn insert_id(&mut self, id: BlockId, holder: Option<I>) -> Result<(), Error>
fn process_header( &mut self, header: &J::Header ) -> Result<(BlockId, BlockId), Error>
sourcepub fn update_block_identifier(
&mut self,
id: &BlockId,
holder: Option<I>,
required: bool
) -> Result<bool, Error>
pub fn update_block_identifier( &mut self, id: &BlockId, holder: Option<I>, required: bool ) -> Result<bool, Error>
Updates the provider block identifier, returns whether it became a new explicitly required.
sourcepub fn update_header(
&mut self,
header: &J::Header,
holder: Option<I>,
required: bool
) -> Result<bool, Error>
pub fn update_header( &mut self, header: &J::Header, holder: Option<I>, required: bool ) -> Result<bool, Error>
Updates the provided header, returns:
- If required is set whether it became a new explicitly required.
- Otherwise whether it’s a new descendant of the highest justified.
sourcepub fn update_body(&mut self, header: &J::Header) -> Result<(), Error>
pub fn update_body(&mut self, header: &J::Header) -> Result<(), Error>
Updates the vertex related to the provided header marking it as imported. Returns errors when it’s impossible to do consistently.
sourcefn try_update_highest_justified(&mut self, id: BlockId) -> bool
fn try_update_highest_justified(&mut self, id: BlockId) -> bool
Updates the highest_justified
if the given id is higher.
sourcepub fn update_justification(
&mut self,
justification: J,
holder: Option<I>
) -> Result<bool, Error>
pub fn update_justification( &mut self, justification: J, holder: Option<I> ) -> Result<bool, Error>
Updates the provided justification. Returns whether the vertex became the new highest justified header/block.
fn pick_favourite(&mut self)
fn prune(&mut self, id: &BlockId)
fn prune_level(&mut self, level: BlockNumber)
sourcepub fn try_finalize(&mut self, number: &BlockNumber) -> Option<J>
pub fn try_finalize(&mut self, number: &BlockNumber) -> Option<J>
Attempt to finalize one block, returns the correct justification if successful.
sourcefn branch_knowledge(&self, id: BlockId) -> Option<BranchKnowledge>
fn branch_knowledge(&self, id: BlockId) -> Option<BranchKnowledge>
Returns the BranchKnowledge regarding the given block id, or None if there is no branch at all.
sourcefn prepare_request_info(
&self,
id: &BlockId,
force: bool
) -> Option<(HashSet<I>, BranchKnowledge)>
fn prepare_request_info( &self, id: &BlockId, force: bool ) -> Option<(HashSet<I>, BranchKnowledge)>
Prepare additional info required to create a request for the branch.
Returns None
if we’re not interested in the branch.
Can be forced to fake interest, but only for blocks we know about.
sourcepub fn request_interest(&self, id: &BlockId) -> Interest<I>
pub fn request_interest(&self, id: &BlockId) -> Interest<I>
How much interest we have for requesting the block.
sourcepub fn importable(&self, id: &BlockId) -> bool
pub fn importable(&self, id: &BlockId) -> bool
Whether we would like to eventually import this block.
fn know_most(&self, id: &BlockId) -> HashSet<I>
sourcepub fn behind_finalization(&self) -> u32
pub fn behind_finalization(&self) -> u32
How far behind in finalization are we.
sourcepub fn extension_request(&self) -> ExtensionRequest<I>
pub fn extension_request(&self) -> ExtensionRequest<I>
Returns an extension request with the appropriate data if either:
- We know of a justified header for which we do not have a block, or
- We know of nodes which have children of our favourite block.
sourcepub fn skippable(&self, id: &BlockId) -> bool
pub fn skippable(&self, id: &BlockId) -> bool
Whether this block should be skipped during importing. It either needs to be already imported, or too old to be checked.
sourcepub fn favourite_block(&self) -> BlockId
pub fn favourite_block(&self) -> BlockId
The ID of the favourite block, i.e. the one for which we will accept imports of children.
Auto Trait Implementations§
impl<I, J> RefUnwindSafe for Forest<I, J>where
I: RefUnwindSafe,
J: RefUnwindSafe,
impl<I, J> Send for Forest<I, J>where
I: Send,
impl<I, J> Sync for Forest<I, J>where
I: Sync,
impl<I, J> Unpin for Forest<I, J>where
J: Unpin,
impl<I, J> UnwindSafe for Forest<I, J>where
I: RefUnwindSafe,
J: UnwindSafe,
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
§fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
fn checked_from<T>(t: T) -> Option<Self>where
Self: TryFrom<T>,
§fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
fn checked_into<T>(self) -> Option<T>where
Self: TryInto<T>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more§impl<T> IsType<T> for T
impl<T> IsType<T> for T
§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
§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 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 S
impl<T, S> UniqueSaturatedInto<T> for S
§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
T
.