Trait sc_consensus_slots::SimpleSlotWorker
source · [−]pub trait SimpleSlotWorker<B: BlockT> {
type BlockImport: BlockImport<B, Transaction = <Self::Proposer as Proposer<B>>::Transaction> + Send + 'static;
type SyncOracle: SyncOracle;
type CreateProposer: Future<Output = Result<Self::Proposer, Error>> + Send + Unpin + 'static;
type Proposer: Proposer<B>;
type Claim: Send + 'static;
type EpochData: Send + 'static;
Show 15 methods
fn logging_target(&self) -> &'static str;
fn block_import(&self) -> Arc<Mutex<Self::BlockImport>>;
fn epoch_data(
&self,
header: &B::Header,
slot: Slot
) -> Result<Self::EpochData, Error>;
fn authorities_len(&self, epoch_data: &Self::EpochData) -> Option<usize>;
fn claim_slot(
&self,
header: &B::Header,
slot: Slot,
epoch_data: &Self::EpochData
) -> Option<Self::Claim>;
fn pre_digest_data(
&self,
slot: Slot,
claim: &Self::Claim
) -> Vec<DigestItem<B::Hash>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
;
fn block_import_params(
&self
) -> Box<dyn Fn(B::Header, &B::Hash, Vec<B::Extrinsic>, StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>, Self::Claim, Self::EpochData) -> Result<BlockImportParams<B, <Self::BlockImport as BlockImport<B>>::Transaction>, Error> + Send + 'static>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
;
fn force_authoring(&self) -> bool;
fn sync_oracle(&mut self) -> &mut Self::SyncOracle;
fn proposer(&mut self, block: &B::Header) -> Self::CreateProposer;
fn notify_slot(
&self,
_header: &B::Header,
_slot: Slot,
_epoch_data: &Self::EpochData
) { ... }
fn should_backoff(&self, _slot: Slot, _chain_head: &B::Header) -> bool { ... }
fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration { ... }
fn proposing_remaining_duration(
&self,
_head: &B::Header,
slot_info: &SlotInfo
) -> Option<Duration> { ... }
fn on_slot(
&mut self,
chain_head: B::Header,
slot_info: SlotInfo
) -> Pin<Box<dyn Future<Output = Option<SlotResult<B>>> + Send>>
where
<Self::Proposer as Proposer<B>>::Proposal: Unpin + Send + 'static,
{ ... }
}
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.
Associated Types
type BlockImport: BlockImport<B, Transaction = <Self::Proposer as Proposer<B>>::Transaction> + Send + 'static
type BlockImport: BlockImport<B, Transaction = <Self::Proposer as Proposer<B>>::Transaction> + Send + 'static
A handle to a BlockImport
.
type SyncOracle: SyncOracle
type SyncOracle: SyncOracle
A handle to a SyncOracle
.
The type of future resolving to the proposer.
Required methods
fn logging_target(&self) -> &'static str
fn logging_target(&self) -> &'static str
The logging target to use when logging messages.
fn block_import(&self) -> Arc<Mutex<Self::BlockImport>>
fn block_import(&self) -> Arc<Mutex<Self::BlockImport>>
A handle to a BlockImport
.
Returns the epoch data necessary for authoring. For time-dependent epochs, use the provided slot number as a canonical source of time.
Returns the number of authorities given the epoch data. None indicate that the authorities information is incomplete.
Tries to claim the given slot, returning an object with claim data if successful.
Return the pre digest data to include in a block authored with the given claim.
fn block_import_params(
&self
) -> Box<dyn Fn(B::Header, &B::Hash, Vec<B::Extrinsic>, StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>, Self::Claim, Self::EpochData) -> Result<BlockImportParams<B, <Self::BlockImport as BlockImport<B>>::Transaction>, Error> + Send + 'static>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
fn block_import_params(
&self
) -> Box<dyn Fn(B::Header, &B::Hash, Vec<B::Extrinsic>, StorageChanges<<Self::BlockImport as BlockImport<B>>::Transaction, B>, Self::Claim, Self::EpochData) -> Result<BlockImportParams<B, <Self::BlockImport as BlockImport<B>>::Transaction>, Error> + Send + 'static>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;
Returns a function which produces a BlockImportParams
.
Whether to force authoring if offline.
fn sync_oracle(&mut self) -> &mut Self::SyncOracle
fn sync_oracle(&mut self) -> &mut Self::SyncOracle
Returns a handle to a SyncOracle
.
fn 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.
Provided methods
fn notify_slot(
&self,
_header: &B::Header,
_slot: Slot,
_epoch_data: &Self::EpochData
)
fn notify_slot(
&self,
_header: &B::Header,
_slot: Slot,
_epoch_data: &Self::EpochData
)
Notifies the given slot. Similar to claim_slot
, but will be called no matter whether we
need to author blocks or not.
fn 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
.
fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration
fn slot_remaining_duration(&self, slot_info: &SlotInfo) -> Duration
Remaining duration of the slot.
Remaining duration for proposing. None means unlimited.