mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 23:18:01 +00:00
Small slots refactor (#2780)
* Deprecate SlotWorker::on_start * start_slot_worker no longer needs an Arc * start_slot_worker now always succeeds * Removed on_exit parameter from start_*_worker * Minor doc * Fix node-template
This commit is contained in:
committed by
DemiMarie-parity
parent
eaa0ab014a
commit
67bdfc7d8e
@@ -65,7 +65,7 @@ use srml_aura::{
|
||||
};
|
||||
use substrate_telemetry::{telemetry, CONSENSUS_TRACE, CONSENSUS_DEBUG, CONSENSUS_WARN, CONSENSUS_INFO};
|
||||
|
||||
use slots::{CheckedHeader, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation};
|
||||
use slots::{CheckedHeader, SlotData, SlotWorker, SlotInfo, SlotCompatible, slot_now, check_equivocation};
|
||||
|
||||
pub use aura_primitives::*;
|
||||
pub use consensus_common::{SyncOracle, ExtraVerification};
|
||||
@@ -125,7 +125,7 @@ impl SlotCompatible for AuraSlotCompatible {
|
||||
}
|
||||
|
||||
/// Start the aura worker. The returned future should be run in a tokio runtime.
|
||||
pub fn start_aura<B, C, SC, E, I, P, SO, Error, OnExit, H>(
|
||||
pub fn start_aura<B, C, SC, E, I, P, SO, Error, H>(
|
||||
slot_duration: SlotDuration,
|
||||
local_key: Arc<P>,
|
||||
client: Arc<C>,
|
||||
@@ -133,7 +133,6 @@ pub fn start_aura<B, C, SC, E, I, P, SO, Error, OnExit, H>(
|
||||
block_import: Arc<I>,
|
||||
env: Arc<E>,
|
||||
sync_oracle: SO,
|
||||
on_exit: OnExit,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
force_authoring: bool,
|
||||
) -> Result<impl Future<Item=(), Error=()>, consensus_common::Error> where
|
||||
@@ -156,25 +155,26 @@ pub fn start_aura<B, C, SC, E, I, P, SO, Error, OnExit, H>(
|
||||
I: BlockImport<B> + Send + Sync + 'static,
|
||||
Error: ::std::error::Error + Send + From<::consensus_common::Error> + From<I::Error> + 'static,
|
||||
SO: SyncOracle + Send + Sync + Clone,
|
||||
OnExit: Future<Item=(), Error=()>,
|
||||
{
|
||||
let worker = AuraWorker {
|
||||
client: client.clone(),
|
||||
block_import,
|
||||
env,
|
||||
local_key,
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
sync_oracle: sync_oracle.clone(),
|
||||
force_authoring,
|
||||
};
|
||||
slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible, _>(
|
||||
register_aura_inherent_data_provider(
|
||||
&inherent_data_providers,
|
||||
slot_duration.0.slot_duration()
|
||||
)?;
|
||||
Ok(slots::start_slot_worker::<_, _, _, _, _, AuraSlotCompatible>(
|
||||
slot_duration.0,
|
||||
select_chain,
|
||||
Arc::new(worker),
|
||||
worker,
|
||||
sync_oracle,
|
||||
on_exit,
|
||||
inherent_data_providers
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
struct AuraWorker<C, E, I, P, SO> {
|
||||
@@ -183,7 +183,6 @@ struct AuraWorker<C, E, I, P, SO> {
|
||||
env: Arc<E>,
|
||||
local_key: Arc<P>,
|
||||
sync_oracle: SO,
|
||||
inherent_data_providers: InherentDataProviders,
|
||||
force_authoring: bool,
|
||||
}
|
||||
|
||||
@@ -208,13 +207,6 @@ impl<H, B, C, E, I, P, Error, SO> SlotWorker<B> for AuraWorker<C, E, I, P, SO> w
|
||||
{
|
||||
type OnSlot = Box<dyn Future<Item=(), Error=consensus_common::Error> + Send>;
|
||||
|
||||
fn on_start(
|
||||
&self,
|
||||
slot_duration: u64
|
||||
) -> Result<(), consensus_common::Error> {
|
||||
register_aura_inherent_data_provider(&self.inherent_data_providers, slot_duration)
|
||||
}
|
||||
|
||||
fn on_slot(
|
||||
&self,
|
||||
chain_head: B::Header,
|
||||
@@ -902,7 +894,7 @@ mod tests {
|
||||
&inherent_data_providers, slot_duration.get()
|
||||
).expect("Registers aura inherent data provider");
|
||||
|
||||
let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _, _>(
|
||||
let aura = start_aura::<_, _, _, _, _, sr25519::Pair, _, _, _>(
|
||||
slot_duration,
|
||||
Arc::new(key.clone().into()),
|
||||
client.clone(),
|
||||
@@ -910,7 +902,6 @@ mod tests {
|
||||
client,
|
||||
environ.clone(),
|
||||
DummyOracle,
|
||||
futures::empty(),
|
||||
inherent_data_providers,
|
||||
false,
|
||||
).expect("Starts aura");
|
||||
|
||||
Reference in New Issue
Block a user