Struct phron_finality::sync::handler::Handler
source · pub struct Handler<B, I, J, CS, V, F, BI>where
J: Justification,
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
I: PeerId,
CS: ChainStatus<B, J>,
V: Verifier<J>,
F: Finalizer<J>,
BI: BlockImport<B>,{
chain_status: CS,
verifier: V,
finalizer: F,
forest: Forest<I, J>,
session_info: SessionBoundaryInfo,
block_importer: BI,
missed_import_data: MissedImportData,
sync_oracle: SyncOracle,
phantom: PhantomData<B>,
}
Expand description
Handler for data incoming from the network.
Fields§
§chain_status: CS
§verifier: V
§finalizer: F
§forest: Forest<I, J>
§session_info: SessionBoundaryInfo
§block_importer: BI
§missed_import_data: MissedImportData
§sync_oracle: SyncOracle
§phantom: PhantomData<B>
Implementations§
source§impl<B, I, J, CS, V, F, BI> Handler<B, I, J, CS, V, F, BI>where
J: Justification,
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
I: PeerId,
CS: ChainStatus<B, J>,
V: Verifier<J>,
F: Finalizer<J>,
BI: BlockImport<B>,
impl<B, I, J, CS, V, F, BI> Handler<B, I, J, CS, V, F, BI>where
J: Justification,
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
I: PeerId,
CS: ChainStatus<B, J>,
V: Verifier<J>,
F: Finalizer<J>,
BI: BlockImport<B>,
sourcepub fn new(
database_io: DatabaseIO<B, J, CS, F, BI>,
verifier: V,
sync_oracle: SyncOracle,
session_info: SessionBoundaryInfo
) -> Result<Self, <Self as HandlerTypes>::Error>
pub fn new( database_io: DatabaseIO<B, J, CS, F, BI>, verifier: V, sync_oracle: SyncOracle, session_info: SessionBoundaryInfo ) -> Result<Self, <Self as HandlerTypes>::Error>
New handler with the provided chain interfaces.
fn try_finalize(&mut self) -> Result<(), <Self as HandlerTypes>::Error>
sourcepub fn block_imported(
&mut self,
header: J::Header
) -> Result<(), <Self as HandlerTypes>::Error>
pub fn block_imported( &mut self, header: J::Header ) -> Result<(), <Self as HandlerTypes>::Error>
Inform the handler that a block has been imported.
sourcepub fn handle_request(
&mut self,
request: Request<J>
) -> Result<Action<B, J>, <Self as HandlerTypes>::Error>
pub fn handle_request( &mut self, request: Request<J> ) -> Result<Action<B, J>, <Self as HandlerTypes>::Error>
Handle a request for potentially substantial amounts of data.
Returns what action we should take in response to the request. We either do nothing, request new interesting block to us or send a response containing path of justifications, blocks and headers. We try to be as helpful as we can, sometimes including more information from what was requested, sometimes ignoring their requested id if we know it makes sense.
sourcepub fn handle_chain_extension_request(
&mut self,
state: State<J>
) -> Result<Action<B, J>, <Self as HandlerTypes>::Error>
pub fn handle_chain_extension_request( &mut self, state: State<J> ) -> Result<Action<B, J>, <Self as HandlerTypes>::Error>
Handle a chain extension request.
First treats it as a request for our favourite block with their favourite block as the top imported. If that fails due to our favourite block not being a descendant of theirs, it falls back to attempting to send any finalized blocks the requester doesn’t have.
sourcefn handle_justification(
&mut self,
justification: J::Unverified,
maybe_peer: Option<I>
) -> Result<bool, <Self as HandlerTypes>::Error>
fn handle_justification( &mut self, justification: J::Unverified, maybe_peer: Option<I> ) -> Result<bool, <Self as HandlerTypes>::Error>
Handle a single unverified justification. Return whether this justification was higher than the previously known highest justification.
sourcefn verify_header(
&mut self,
header: <<J as Justification>::Header as Header>::Unverified
) -> Result<J::Header, <Self as HandlerTypes>::Error>
fn verify_header( &mut self, header: <<J as Justification>::Header as Header>::Unverified ) -> Result<J::Header, <Self as HandlerTypes>::Error>
Verify an unverified header.
sourcepub fn handle_justification_from_user(
&mut self,
justification: J::Unverified
) -> Result<bool, <Self as HandlerTypes>::Error>
pub fn handle_justification_from_user( &mut self, justification: J::Unverified ) -> Result<bool, <Self as HandlerTypes>::Error>
Handle a justification from the user, returning whether it became the new highest justification.
sourcepub fn handle_state_response(
&mut self,
justification: J::Unverified,
maybe_justification: Option<J::Unverified>,
peer: I
) -> (bool, Option<<Self as HandlerTypes>::Error>)
pub fn handle_state_response( &mut self, justification: J::Unverified, maybe_justification: Option<J::Unverified>, peer: I ) -> (bool, Option<<Self as HandlerTypes>::Error>)
Handle a state response returning whether it resulted in a new highest justified block and possibly an error.
If no error is returned, it means that the whole state response was processed correctly. Otherwise, the response might have been processed partially, or dropped. In any case, the Handler finishes in a sane state.
sourcepub fn handle_request_response(
&mut self,
response_items: Vec<ResponseItem<B, J>>,
peer: I
) -> (bool, Option<<Self as HandlerTypes>::Error>)
pub fn handle_request_response( &mut self, response_items: Vec<ResponseItem<B, J>>, peer: I ) -> (bool, Option<<Self as HandlerTypes>::Error>)
Handle a request response returning whether it resulted in a new highest justified block and possibly an error.
If no error is returned, it means that the whole request response was processed correctly. Otherwise, the response might have been processed partially, or dropped. In any case, the Handler finishes in a sane state.
Note that this method does not verify nor import blocks. The received blocks are stored in a buffer, and might be silently discarded in the future if the import fails.
fn last_justification_unverified( &self, session: SessionId ) -> Result<J::Unverified, <Self as HandlerTypes>::Error>
sourcepub fn handle_state(
&mut self,
state: State<J>,
peer: I
) -> Result<HandleStateAction<B, J>, <Self as HandlerTypes>::Error>
pub fn handle_state( &mut self, state: State<J>, peer: I ) -> Result<HandleStateAction<B, J>, <Self as HandlerTypes>::Error>
Handle a state broadcast returning the actions we should take in response.
sourcepub fn state(&self) -> Result<State<J>, <Self as HandlerTypes>::Error>
pub fn state(&self) -> Result<State<J>, <Self as HandlerTypes>::Error>
The current state of our database.
sourcepub fn interest_provider(&self) -> InterestProvider<'_, I, J>
pub fn interest_provider(&self) -> InterestProvider<'_, I, J>
A handle for requesting Interest.
sourcepub fn handle_internal_request(
&mut self,
id: &BlockId
) -> Result<bool, <Self as HandlerTypes>::Error>
pub fn handle_internal_request( &mut self, id: &BlockId ) -> Result<bool, <Self as HandlerTypes>::Error>
Handle an internal block request.
Returns true
if this was the first time something indicated interest in this block.
sourcepub fn extension_request(&self) -> ExtensionRequest<I>
pub fn extension_request(&self) -> ExtensionRequest<I>
Returns the extension request we could be making right now.
sourcepub fn handle_own_block(&mut self, block: B) -> Vec<ResponseItem<B, J>>
pub fn handle_own_block(&mut self, block: B) -> Vec<ResponseItem<B, J>>
Handle a block freshly created by this node. Imports it and returns a form of it that can be broadcast.
Trait Implementations§
source§impl<B, I, J, CS, V, F, BI> HandlerTypes for Handler<B, I, J, CS, V, F, BI>where
J: Justification,
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
I: PeerId,
CS: ChainStatus<B, J>,
V: Verifier<J>,
F: Finalizer<J>,
BI: BlockImport<B>,
impl<B, I, J, CS, V, F, BI> HandlerTypes for Handler<B, I, J, CS, V, F, BI>where
J: Justification,
B: Block<UnverifiedHeader = <<J as Justification>::Header as Header>::Unverified>,
I: PeerId,
CS: ChainStatus<B, J>,
V: Verifier<J>,
F: Finalizer<J>,
BI: BlockImport<B>,
Auto Trait Implementations§
impl<B, I, J, CS, V, F, BI> !RefUnwindSafe for Handler<B, I, J, CS, V, F, BI>
impl<B, I, J, CS, V, F, BI> Send for Handler<B, I, J, CS, V, F, BI>
impl<B, I, J, CS, V, F, BI> Sync for Handler<B, I, J, CS, V, F, BI>
impl<B, I, J, CS, V, F, BI> Unpin for Handler<B, I, J, CS, V, F, BI>
impl<B, I, J, CS, V, F, BI> !UnwindSafe for Handler<B, I, J, CS, V, F, BI>
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
.