Skip to content
Snippets Groups Projects
Commit 71d3863a authored by pscott's avatar pscott Committed by GitHub
Browse files

Remove background_tasks field in ServiceBuilder (#5830)

* Spawn tasks instead of pushing them to background_tasks

* Remove unnecessary mut keyword for self

* Remove background_tasks field in ServiceBuilder
parent aff24d6f
No related merge requests found
......@@ -96,7 +96,6 @@ pub struct ServiceBuilder<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp,
rpc_extensions: TRpc,
remote_backend: Option<Arc<dyn RemoteBlockchain<TBl>>>,
marker: PhantomData<(TBl, TRtApi)>,
background_tasks: Vec<(&'static str, BackgroundTask)>,
block_announce_validator_builder: Option<Box<dyn FnOnce(Arc<TCl>) -> Box<dyn BlockAnnounceValidator<TBl> + Send> + Send>>,
}
......@@ -311,7 +310,6 @@ impl ServiceBuilder<(), (), (), (), (), (), (), (), (), (), ()> {
transaction_pool: Arc::new(()),
rpc_extensions: Default::default(),
remote_backend: None,
background_tasks: Default::default(),
block_announce_validator_builder: None,
marker: PhantomData,
})
......@@ -395,7 +393,6 @@ impl ServiceBuilder<(), (), (), (), (), (), (), (), (), (), ()> {
transaction_pool: Arc::new(()),
rpc_extensions: Default::default(),
remote_backend: Some(remote_blockchain),
background_tasks: Default::default(),
block_announce_validator_builder: None,
marker: PhantomData,
})
......@@ -469,7 +466,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -514,7 +510,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -553,7 +548,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -618,7 +612,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -647,7 +640,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
/// Defines which transaction pool to use.
pub fn with_transaction_pool<UExPool>(
mut self,
self,
transaction_pool_builder: impl FnOnce(
sc_transaction_pool::txpool::Options,
Arc<TCl>,
......@@ -665,7 +658,7 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
)?;
if let Some(background_task) = background_task{
self.background_tasks.push(("txpool-background", background_task));
self.task_manager.spawn_handle().spawn("txpool-background", background_task);
}
Ok(ServiceBuilder {
......@@ -682,7 +675,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: Arc::new(transaction_pool),
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -711,7 +703,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: self.block_announce_validator_builder,
marker: self.marker,
})
......@@ -740,7 +731,6 @@ impl<TBl, TRtApi, TCl, TFchr, TSc, TImpQu, TFprb, TFpp, TExPool, TRpc, Backend>
transaction_pool: self.transaction_pool,
rpc_extensions: self.rpc_extensions,
remote_backend: self.remote_backend,
background_tasks: self.background_tasks,
block_announce_validator_builder: Some(Box::new(block_announce_validator_builder)),
marker: self.marker,
})
......@@ -852,7 +842,6 @@ ServiceBuilder<
transaction_pool,
rpc_extensions,
remote_backend,
background_tasks,
block_announce_validator_builder,
} = self;
......@@ -947,12 +936,6 @@ ServiceBuilder<
let spawn_handle = task_manager.spawn_handle();
// Spawn background tasks which were stacked during the
// service building.
for (title, background_task) in background_tasks {
spawn_handle.spawn(title, background_task);
}
{
// block notifications
let txpool = Arc::downgrade(&transaction_pool);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment