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>,

source

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.

source

fn try_finalize(&mut self) -> Result<(), <Self as HandlerTypes>::Error>

source

pub fn block_imported( &mut self, header: J::Header ) -> Result<(), <Self as HandlerTypes>::Error>

Inform the handler that a block has been imported.

source

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.

source

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.

source

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.

source

fn verify_header( &mut self, header: <<J as Justification>::Header as Header>::Unverified ) -> Result<J::Header, <Self as HandlerTypes>::Error>

Verify an unverified header.

source

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.

source

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.

source

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.

source

fn last_justification_unverified( &self, session: SessionId ) -> Result<J::Unverified, <Self as HandlerTypes>::Error>

source

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.

source

pub fn state(&self) -> Result<State<J>, <Self as HandlerTypes>::Error>

The current state of our database.

source

pub fn interest_provider(&self) -> InterestProvider<'_, I, J>

A handle for requesting Interest.

source

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.

source

pub fn extension_request(&self) -> ExtensionRequest<I>

Returns the extension request we could be making right now.

source

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>,

§

type Error = Error<B, J, CS, V, F>

What can go wrong when handling a piece of data.

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>
where F: Send, I: Send, V: Send,

§

impl<B, I, J, CS, V, F, BI> Sync for Handler<B, I, J, CS, V, F, BI>
where BI: Sync, F: Sync, I: Sync, V: Sync,

§

impl<B, I, J, CS, V, F, BI> Unpin for Handler<B, I, J, CS, V, F, BI>
where B: Unpin, BI: Unpin, CS: Unpin, F: Unpin, J: Unpin, V: Unpin,

§

impl<B, I, J, CS, V, F, BI> !UnwindSafe for Handler<B, I, J, CS, V, F, BI>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedConversion for T

§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn from_ref(t: &T) -> &T

Cast reference.
§

fn into_ref(&self) -> &T

Cast reference.
§

fn from_mut(t: &mut T) -> &mut T

Cast mutable reference.
§

fn into_mut(&mut self) -> &mut T

Cast mutable reference.
§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<T> SaturatedConversion for T

§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> JsonSchemaMaybe for T

§

impl<T> MaybeSend for T
where T: Send,