core, node: use grandpa block import for locally sealed aura blocks (#1167)

* core, node: use grandpa block import for locally sealed aura blocks

* core: impl DerefMut for FullComponents

* node: take grandpa_import_setup from service config
This commit is contained in:
André Silva
2018-11-26 14:29:13 +00:00
committed by Robert Habermeier
parent 675c3b0500
commit b7e0db725d
4 changed files with 27 additions and 17 deletions
+7 -3
View File
@@ -146,17 +146,19 @@ impl<Hash, AuthorityId> CompatibleDigestItem for generic::DigestItem<Hash, Autho
}
/// Start the aura worker. This should be run in a tokio runtime.
pub fn start_aura<B, C, E, SO, Error>(
pub fn start_aura<B, C, E, I, SO, Error>(
config: Config,
client: Arc<C>,
block_import: Arc<I>,
env: Arc<E>,
sync_oracle: SO,
)
-> impl Future<Item=(),Error=()> where
B: Block,
C: Authorities<B, Error=Error> + BlockImport<B, Error=Error> + ChainHead<B>,
C: Authorities<B, Error=Error> + ChainHead<B>,
E: Environment<B, Error=Error>,
E::Proposer: Proposer<B, Error=Error>,
I: BlockImport<B, Error=Error>,
SO: SyncOracle + Send + Clone,
DigestItemFor<B>: CompatibleDigestItem,
Error: ::std::error::Error + Send + 'static + From<::consensus_common::Error>,
@@ -164,6 +166,7 @@ pub fn start_aura<B, C, E, SO, Error>(
let make_authorship = move || {
let config = config.clone();
let client = client.clone();
let block_import = block_import.clone();
let env = env.clone();
let sync_oracle = sync_oracle.clone();
@@ -225,7 +228,7 @@ pub fn start_aura<B, C, E, SO, Error>(
}
};
let block_import = client.clone();
let block_import = block_import.clone();
Either::A(proposal_work
.map(move |b| {
let (header, body) = b.deconstruct();
@@ -542,6 +545,7 @@ mod tests {
local_key: Some(Arc::new(key.clone().into())),
slot_duration: SLOT_DURATION
},
client.clone(),
client,
environ.clone(),
DummyOracle,
+7 -1
View File
@@ -16,7 +16,7 @@
//! Substrate service components.
use std::{sync::Arc, net::SocketAddr, marker::PhantomData, ops::Deref};
use std::{sync::Arc, net::SocketAddr, marker::PhantomData, ops::Deref, ops::DerefMut};
use serde::{Serialize, de::DeserializeOwned};
use tokio::runtime::TaskExecutor;
use chain_spec::{ChainSpec, Properties};
@@ -369,6 +369,12 @@ impl<Factory: ServiceFactory> Deref for FullComponents<Factory> {
}
}
impl<Factory: ServiceFactory> DerefMut for FullComponents<Factory> {
fn deref_mut(&mut self) -> &mut Service<Self> {
&mut self.service
}
}
impl<Factory: ServiceFactory> Components for FullComponents<Factory> {
type Factory = Factory;
type Executor = FullExecutor<Factory>;
-4
View File
@@ -310,10 +310,6 @@ impl<Components> Service<Components>
None
}
}
pub fn config(&self) -> &FactoryFullConfiguration<Components::Factory> {
&self.config
}
}
impl<Components> Service<Components> where Components: components::Components {