Trait sc_consensus_slots::SimpleSlotWorker

source ·
pub trait SimpleSlotWorker<B: BlockT> {
    type BlockImport: BlockImport<B> + Send + 'static;
    type SyncOracle: SyncOracle;
    type JustificationSyncLink: JustificationSyncLink<B>;
    type CreateProposer: Future<Output = Result<Self::Proposer, Error>> + Send + Unpin + 'static;
    type Proposer: Proposer<B> + Send;
    type Claim: Send + Sync + 'static;
    type AuxData: Send + Sync + 'static;

Show 18 methods // Required methods fn logging_target(&self) -> &'static str; fn block_import(&mut self) -> &mut Self::BlockImport; fn aux_data( &self, header: &B::Header, slot: Slot ) -> Result<Self::AuxData, Error>; fn authorities_len(&self, aux_data: &Self::AuxData) -> Option<usize>; fn claim_slot<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, header: &'life1 B::Header, slot: Slot, aux_data: &'life2 Self::AuxData ) -> Pin<Box<dyn Future<Output = Option<Self::Claim>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn pre_digest_data( &self, slot: Slot, claim: &Self::Claim ) -> Vec<DigestItem>; fn block_import_params<'life0, 'life1, 'async_trait>( &'life0 self, header: B::Header, header_hash: &'life1 B::Hash, body: Vec<B::Extrinsic>, storage_changes: StorageChanges<B>, public: Self::Claim, aux_data: Self::AuxData ) -> Pin<Box<dyn Future<Output = Result<BlockImportParams<B>, Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn force_authoring(&self) -> bool; fn sync_oracle(&mut self) -> &mut Self::SyncOracle; fn justification_sync_link(&mut self) -> &mut Self::JustificationSyncLink; fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer; fn telemetry(&self) -> Option<TelemetryHandle>; fn proposing_remaining_duration(&self, slot_info: &SlotInfo<B>) -> Duration; // Provided methods fn notify_slot( &self, _header: &B::Header, _slot: Slot, _aux_data: &Self::AuxData ) { ... } fn should_backoff(&self, _slot: Slot, _chain_head: &B::Header) -> bool { ... } fn propose<'life0, 'life1, 'async_trait>( &'life0 mut self, proposer: Self::Proposer, claim: &'life1 Self::Claim, slot_info: SlotInfo<B>, end_proposing_at: Instant ) -> Pin<Box<dyn Future<Output = Option<Proposal<B, <Self::Proposer as Proposer<B>>::Proof>>> + Send + 'async_trait>> where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn create_inherent_data<'life0, 'life1, 'async_trait>( slot_info: &'life0 SlotInfo<B>, logging_target: &'life1 str, end_proposing_at: Instant ) -> Pin<Box<dyn Future<Output = Option<InherentData>> + Send + 'async_trait>> where 'life0: 'async_trait, 'life1: 'async_trait { ... } fn on_slot<'life0, 'async_trait>( &'life0 mut self, slot_info: SlotInfo<B> ) -> Pin<Box<dyn Future<Output = Option<SlotResult<B, <Self::Proposer as Proposer<B>>::Proof>>> + Send + 'async_trait>> where Self: Sync + Send + 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

A skeleton implementation for SlotWorker which tries to claim a slot at its beginning and tries to produce a block if successfully claimed, timing out if block production takes too long.

Required Associated Types§

source

type BlockImport: BlockImport<B> + Send + 'static

A handle to a BlockImport.

source

type SyncOracle: SyncOracle

A handle to a SyncOracle.

A handle to a JustificationSyncLink, allows hooking into the sync module to control the justification sync process.

source

type CreateProposer: Future<Output = Result<Self::Proposer, Error>> + Send + Unpin + 'static

The type of future resolving to the proposer.

source

type Proposer: Proposer<B> + Send

The type of proposer to use to build blocks.

source

type Claim: Send + Sync + 'static

Data associated with a slot claim.

source

type AuxData: Send + Sync + 'static

Auxiliary data necessary for authoring.

Required Methods§

source

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

The logging target to use when logging messages.

source

fn block_import(&mut self) -> &mut Self::BlockImport

A handle to a BlockImport.

source

fn aux_data( &self, header: &B::Header, slot: Slot ) -> Result<Self::AuxData, Error>

Returns the auxiliary data necessary for authoring.

source

fn authorities_len(&self, aux_data: &Self::AuxData) -> Option<usize>

Returns the number of authorities. None indicate that the authorities information is incomplete.

source

fn claim_slot<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, header: &'life1 B::Header, slot: Slot, aux_data: &'life2 Self::AuxData ) -> Pin<Box<dyn Future<Output = Option<Self::Claim>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Tries to claim the given slot, returning an object with claim data if successful.

source

fn pre_digest_data(&self, slot: Slot, claim: &Self::Claim) -> Vec<DigestItem>

Return the pre digest data to include in a block authored with the given claim.

source

fn block_import_params<'life0, 'life1, 'async_trait>( &'life0 self, header: B::Header, header_hash: &'life1 B::Hash, body: Vec<B::Extrinsic>, storage_changes: StorageChanges<B>, public: Self::Claim, aux_data: Self::AuxData ) -> Pin<Box<dyn Future<Output = Result<BlockImportParams<B>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Returns a function which produces a BlockImportParams.

source

fn force_authoring(&self) -> bool

Whether to force authoring if offline.

source

fn sync_oracle(&mut self) -> &mut Self::SyncOracle

Returns a handle to a SyncOracle.

Returns a handle to a JustificationSyncLink.

source

fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer

Returns a Proposer to author on top of the given block.

source

fn telemetry(&self) -> Option<TelemetryHandle>

Returns a TelemetryHandle if any.

source

fn proposing_remaining_duration(&self, slot_info: &SlotInfo<B>) -> Duration

Remaining duration for proposing.

Provided Methods§

source

fn notify_slot( &self, _header: &B::Header, _slot: Slot, _aux_data: &Self::AuxData )

Notifies the given slot. Similar to claim_slot, but will be called no matter whether we need to author blocks or not.

source

fn should_backoff(&self, _slot: Slot, _chain_head: &B::Header) -> bool

Returns whether the block production should back off.

By default this function always returns false.

An example strategy that back offs if the finalized head is lagging too much behind the tip is implemented by BackoffAuthoringOnFinalizedHeadLagging.

source

fn propose<'life0, 'life1, 'async_trait>( &'life0 mut self, proposer: Self::Proposer, claim: &'life1 Self::Claim, slot_info: SlotInfo<B>, end_proposing_at: Instant ) -> Pin<Box<dyn Future<Output = Option<Proposal<B, <Self::Proposer as Proposer<B>>::Proof>>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Propose a block by Proposer.

source

fn create_inherent_data<'life0, 'life1, 'async_trait>( slot_info: &'life0 SlotInfo<B>, logging_target: &'life1 str, end_proposing_at: Instant ) -> Pin<Box<dyn Future<Output = Option<InherentData>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Calls create_inherent_data and handles errors.

source

fn on_slot<'life0, 'async_trait>( &'life0 mut self, slot_info: SlotInfo<B> ) -> Pin<Box<dyn Future<Output = Option<SlotResult<B, <Self::Proposer as Proposer<B>>::Proof>>> + Send + 'async_trait>>
where Self: Sync + Send + 'async_trait, 'life0: 'async_trait,

Implements SlotWorker::on_slot.

Object Safety§

This trait is not object safe.

Implementors§