Skip to content
Snippets Groups Projects
Unverified Commit 22fdbdd9 authored by bgallois's avatar bgallois
Browse files

fix manual and instant sealing

parent 586b23ea
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ use sp_keystore::KeystorePtr; ...@@ -37,6 +37,7 @@ use sp_keystore::KeystorePtr;
use std::sync::Arc; use std::sync::Arc;
/// Extra dependencies for BABE. /// Extra dependencies for BABE.
#[derive(Clone)]
pub struct BabeDeps { pub struct BabeDeps {
/// A handle to the BABE worker for issuing requests. /// A handle to the BABE worker for issuing requests.
pub babe_worker_handle: BabeWorkerHandle<Block>, pub babe_worker_handle: BabeWorkerHandle<Block>,
...@@ -61,7 +62,7 @@ pub struct FullDeps<C, P, SC> { ...@@ -61,7 +62,7 @@ pub struct FullDeps<C, P, SC> {
futures::channel::mpsc::Sender<sc_consensus_manual_seal::EngineCommand<sp_core::H256>>, futures::channel::mpsc::Sender<sc_consensus_manual_seal::EngineCommand<sp_core::H256>>,
>, >,
/// BABE specific dependencies. /// BABE specific dependencies.
pub babe: BabeDeps, pub babe: Option<BabeDeps>,
} }
/// Instantiate all full RPC extensions. /// Instantiate all full RPC extensions.
...@@ -95,13 +96,11 @@ where ...@@ -95,13 +96,11 @@ where
babe, babe,
} = deps; } = deps;
if let Some(babe) = babe {
let BabeDeps { let BabeDeps {
babe_worker_handle, babe_worker_handle,
keystore, keystore,
} = babe; } = babe;
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge( module.merge(
Babe::new( Babe::new(
client.clone(), client.clone(),
...@@ -112,6 +111,9 @@ where ...@@ -112,6 +111,9 @@ where
) )
.into_rpc(), .into_rpc(),
)?; )?;
}
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
if let Some(command_sink) = command_sink_opt { if let Some(command_sink) = command_sink_opt {
// We provide the rpc handler with the sending end of the channel to allow the rpc // We provide the rpc handler with the sending end of the channel to allow the rpc
// send EngineCommands to the background block authorship task. // send EngineCommands to the background block authorship task.
......
...@@ -218,7 +218,7 @@ pub fn new_partial<RuntimeApi, Executor>( ...@@ -218,7 +218,7 @@ pub fn new_partial<RuntimeApi, Executor>(
FullGrandpaBlockImport<RuntimeApi, Executor>, FullGrandpaBlockImport<RuntimeApi, Executor>,
>, >,
sc_consensus_babe::BabeLink<Block>, sc_consensus_babe::BabeLink<Block>,
sc_consensus_babe::BabeWorkerHandle<Block>, Option<sc_consensus_babe::BabeWorkerHandle<Block>>,
sc_consensus_grandpa::LinkHalf< sc_consensus_grandpa::LinkHalf<
Block, Block,
FullClient<RuntimeApi, Executor>, FullClient<RuntimeApi, Executor>,
...@@ -291,8 +291,16 @@ where ...@@ -291,8 +291,16 @@ where
client.clone(), client.clone(),
)?; )?;
let (import_queue, babe_worker_handle) = if consensus_manual {
let import_queue = sc_consensus_manual_seal::import_queue(
Box::new(babe_block_import.clone()),
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
);
(import_queue, None)
} else {
let slot_duration = babe_link.config().slot_duration(); let slot_duration = babe_link.config().slot_duration();
let (mut import_queue, babe_worker_handle) = sc_consensus_babe::import_queue( let (queue, handle) = sc_consensus_babe::import_queue(
babe_link.clone(), babe_link.clone(),
babe_block_import.clone(), babe_block_import.clone(),
Some(Box::new(justification_import)), Some(Box::new(justification_import)),
...@@ -312,14 +320,8 @@ where ...@@ -312,14 +320,8 @@ where
config.prometheus_registry(), config.prometheus_registry(),
telemetry.as_ref().map(|x| x.handle()), telemetry.as_ref().map(|x| x.handle()),
)?; )?;
(queue, Some(handle))
if consensus_manual { };
import_queue = sc_consensus_manual_seal::import_queue(
Box::new(babe_block_import.clone()),
&task_manager.spawn_essential_handle(),
config.prometheus_registry(),
);
}
Ok(sc_service::PartialComponents { Ok(sc_service::PartialComponents {
client, client,
...@@ -556,6 +558,14 @@ where ...@@ -556,6 +558,14 @@ where
let select_chain = select_chain.clone(); let select_chain = select_chain.clone();
let chain_spec = config.chain_spec.cloned_box(); let chain_spec = config.chain_spec.cloned_box();
let keystore = keystore_container.keystore().clone(); let keystore = keystore_container.keystore().clone();
let babe_deps = if let Some(babe_worker_handle) = babe_worker_handle {
Some(crate::rpc::BabeDeps {
babe_worker_handle: babe_worker_handle.clone(),
keystore: keystore.clone(),
})
} else {
None
};
Box::new(move |deny_unsafe, _| { Box::new(move |deny_unsafe, _| {
let deps = crate::rpc::FullDeps { let deps = crate::rpc::FullDeps {
...@@ -564,10 +574,7 @@ where ...@@ -564,10 +574,7 @@ where
select_chain: select_chain.clone(), select_chain: select_chain.clone(),
chain_spec: chain_spec.cloned_box(), chain_spec: chain_spec.cloned_box(),
deny_unsafe, deny_unsafe,
babe: crate::rpc::BabeDeps { babe: babe_deps.clone(),
babe_worker_handle: babe_worker_handle.clone(),
keystore: keystore.clone(),
},
command_sink_opt: command_sink_opt.clone(), command_sink_opt: command_sink_opt.clone(),
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment