From cbe35b9bd49cd429d991f39c087f753455d82ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 19 Feb 2021 00:15:26 +0100 Subject: [PATCH] Remove `OnSlot` associated type (#8156) Currently we always use a boxed future everywhere anyway. This also enables us to use a boxed `SlotWorker` (which is required for Cumulus). --- substrate/client/consensus/slots/src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/substrate/client/consensus/slots/src/lib.rs b/substrate/client/consensus/slots/src/lib.rs index d851753921..62b6b452eb 100644 --- a/substrate/client/consensus/slots/src/lib.rs +++ b/substrate/client/consensus/slots/src/lib.rs @@ -71,14 +71,15 @@ pub struct SlotResult { /// The implementation should not make any assumptions of the slot being bound to the time or /// similar. The only valid assumption is that the slot number is always increasing. pub trait SlotWorker { - /// The type of the future that will be returned when a new slot is triggered. - type OnSlot: Future>>; - /// Called when a new slot is triggered. /// /// Returns a future that resolves to a [`SlotResult`] iff a block was successfully built in /// the slot. Otherwise `None` is returned. - fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot; + fn on_slot( + &mut self, + chain_head: B::Header, + slot_info: SlotInfo, + ) -> Pin>> + Send>>; } /// A skeleton implementation for `SlotWorker` which tries to claim a slot at @@ -383,9 +384,11 @@ pub trait SimpleSlotWorker { } impl> SlotWorker for T { - type OnSlot = Pin>> + Send>>; - - fn on_slot(&mut self, chain_head: B::Header, slot_info: SlotInfo) -> Self::OnSlot { + fn on_slot( + &mut self, + chain_head: B::Header, + slot_info: SlotInfo, + ) -> Pin>> + Send>> { SimpleSlotWorker::on_slot(self, chain_head, slot_info) } } @@ -416,7 +419,6 @@ where B: BlockT, C: SelectChain, W: SlotWorker, - W::OnSlot: Unpin, SO: SyncOracle + Send, SC: SlotCompatible + Unpin, T: SlotData + Clone,