Expose that BasicQueue expects blocking spawn (#5860)

* Expose that `BasicQueue` expects blocking spawn

Up to now `BasicQueue` expected a closure that to spawn a `Future`.
This was expected to be a closure that spawns a blocking future.
However, this wasn't documented anywhere. This pr introduces a new trait
`SpawnBlocking` that exposes this requirement to the outside.

* Feedback
This commit is contained in:
Bastian Köcher
2020-05-04 19:40:29 +02:00
committed by GitHub
parent 8549cf5899
commit 9c5536e01a
15 changed files with 90 additions and 48 deletions
+7 -7
View File
@@ -50,7 +50,11 @@ macro_rules! new_full_start {
})?
.with_transaction_pool(|config, client, _fetcher, prometheus_registry| {
let pool_api = sc_transaction_pool::FullChainApi::new(client.clone());
Ok(sc_transaction_pool::BasicPool::new(config, std::sync::Arc::new(pool_api), prometheus_registry))
Ok(sc_transaction_pool::BasicPool::new(
config,
std::sync::Arc::new(pool_api),
prometheus_registry,
))
})?
.with_import_queue(|_config, client, mut select_chain, _transaction_pool, spawn_task_handle| {
let select_chain = select_chain.take()
@@ -68,8 +72,6 @@ macro_rules! new_full_start {
client.clone(),
)?;
let spawner = |future| spawn_task_handle.spawn_blocking("import-queue-worker", future);
let import_queue = sc_consensus_babe::import_queue(
babe_link.clone(),
block_import.clone(),
@@ -77,7 +79,7 @@ macro_rules! new_full_start {
None,
client,
inherent_data_providers.clone(),
spawner,
spawn_task_handle,
)?;
import_setup = Some((block_import, grandpa_link, babe_link));
@@ -308,8 +310,6 @@ pub fn new_light(config: Configuration)
client.clone(),
)?;
let spawner = |future| spawn_task_handle.spawn_blocking("import-queue-worker", future);
let import_queue = sc_consensus_babe::import_queue(
babe_link,
babe_block_import,
@@ -317,7 +317,7 @@ pub fn new_light(config: Configuration)
Some(Box::new(finality_proof_import)),
client.clone(),
inherent_data_providers.clone(),
spawner,
spawn_task_handle,
)?;
Ok((import_queue, finality_proof_request_builder))