SimpleSlotWorker make claim_slot async (#9713)

* SimpleSlotWorker make `claim_slot` async

* FMT
This commit is contained in:
Bastian Köcher
2021-09-07 13:15:44 +02:00
committed by GitHub
parent 5d78dbf27f
commit 224c7f10b9
3 changed files with 33 additions and 27 deletions
+9 -6
View File
@@ -108,7 +108,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
type Claim: Send + 'static;
/// Epoch data necessary for authoring.
type EpochData: Send + 'static;
type EpochData: Send + Sync + 'static;
/// The logging target to use when logging messages.
fn logging_target(&self) -> &'static str;
@@ -129,7 +129,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
fn authorities_len(&self, epoch_data: &Self::EpochData) -> Option<usize>;
/// Tries to claim the given slot, returning an object with claim data if successful.
fn claim_slot(
async fn claim_slot(
&self,
header: &B::Header,
slot: Slot,
@@ -200,7 +200,10 @@ pub trait SimpleSlotWorker<B: BlockT> {
async fn on_slot(
&mut self,
slot_info: SlotInfo<B>,
) -> Option<SlotResult<B, <Self::Proposer as Proposer<B>>::Proof>> {
) -> Option<SlotResult<B, <Self::Proposer as Proposer<B>>::Proof>>
where
Self: Sync,
{
let (timestamp, slot) = (slot_info.timestamp, slot_info.slot);
let telemetry = self.telemetry();
let logging_target = self.logging_target();
@@ -259,7 +262,7 @@ pub trait SimpleSlotWorker<B: BlockT> {
return None
}
let claim = self.claim_slot(&slot_info.chain_head, slot, &epoch_data)?;
let claim = self.claim_slot(&slot_info.chain_head, slot, &epoch_data).await?;
if self.should_backoff(slot, &slot_info.chain_head) {
return None
@@ -415,8 +418,8 @@ pub trait SimpleSlotWorker<B: BlockT> {
}
#[async_trait::async_trait]
impl<B: BlockT, T: SimpleSlotWorker<B> + Send> SlotWorker<B, <T::Proposer as Proposer<B>>::Proof>
for T
impl<B: BlockT, T: SimpleSlotWorker<B> + Send + Sync>
SlotWorker<B, <T::Proposer as Proposer<B>>::Proof> for T
{
async fn on_slot(
&mut self,