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§
Sourcetype BlockImport: BlockImport<B> + Send + 'static
type BlockImport: BlockImport<B> + Send + 'static
A handle to a BlockImport.
Sourcetype SyncOracle: SyncOracle
type SyncOracle: SyncOracle
A handle to a SyncOracle.
Sourcetype JustificationSyncLink: JustificationSyncLink<B>
type JustificationSyncLink: JustificationSyncLink<B>
A handle to a JustificationSyncLink, allows hooking into the sync module to control the
justification sync process.
Required Methods§
Sourcefn logging_target(&self) -> &'static str
fn logging_target(&self) -> &'static str
The logging target to use when logging messages.
Sourcefn block_import(&mut self) -> &mut Self::BlockImport
fn block_import(&mut self) -> &mut Self::BlockImport
A handle to a BlockImport.
Sourcefn aux_data(
&self,
header: &B::Header,
slot: Slot,
) -> Result<Self::AuxData, Error>
fn aux_data( &self, header: &B::Header, slot: Slot, ) -> Result<Self::AuxData, Error>
Returns the auxiliary data necessary for authoring.
Returns the number of authorities. None indicate that the authorities information is incomplete.
Sourcefn 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 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.
Sourcefn pre_digest_data(&self, slot: Slot, claim: &Self::Claim) -> Vec<DigestItem>
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.
Sourcefn 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 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.
Whether to force authoring if offline.
Sourcefn sync_oracle(&mut self) -> &mut Self::SyncOracle
fn sync_oracle(&mut self) -> &mut Self::SyncOracle
Returns a handle to a SyncOracle.
Sourcefn justification_sync_link(&mut self) -> &mut Self::JustificationSyncLink
fn justification_sync_link(&mut self) -> &mut Self::JustificationSyncLink
Returns a handle to a JustificationSyncLink.
Sourcefn proposer(&mut self, block: &B::Header) -> Self::CreateProposer
fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer
Returns a Proposer to author on top of the given block.
Sourcefn proposing_remaining_duration(&self, slot_info: &SlotInfo<B>) -> Duration
fn proposing_remaining_duration(&self, slot_info: &SlotInfo<B>) -> Duration
Remaining duration for proposing.
Provided Methods§
Sourcefn notify_slot(
&self,
_header: &B::Header,
_slot: Slot,
_aux_data: &Self::AuxData,
)
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.
Sourcefn should_backoff(&self, _slot: Slot, _chain_head: &B::Header) -> bool
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.
Sourcefn 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 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.
Sourcefn 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 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.