Simplify a few chain components creation APIs related to the service (#6611)

* Simplify a few chain components creation APIs related to the service

* Fix basic-authorship doc tests

* Remove DefaultQueue

* Update client/service/src/builder.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* Move ExecutionExtensions comment around

* Remove unused BlakeTwo256

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Ashley
2020-07-09 15:43:04 +02:00
committed by GitHub
parent 25de5b5c78
commit 234e7d0c3d
19 changed files with 202 additions and 140 deletions
@@ -84,6 +84,10 @@ pub struct ExecutionExtensions<Block: traits::Block> {
keystore: Option<BareCryptoStorePtr>,
// FIXME: these two are only RwLock because of https://github.com/paritytech/substrate/issues/4587
// remove when fixed.
// To break retain cycle between `Client` and `TransactionPool` we require this
// extension to be a `Weak` reference.
// That's also the reason why it's being registered lazily instead of
// during initialization.
transaction_pool: RwLock<Option<Weak<dyn sp_transaction_pool::OffchainSubmitTransaction<Block>>>>,
extensions_factory: RwLock<Box<dyn ExtensionsFactory>>,
}
@@ -121,13 +125,10 @@ impl<Block: traits::Block> ExecutionExtensions<Block> {
}
/// Register transaction pool extension.
///
/// To break retain cycle between `Client` and `TransactionPool` we require this
/// extension to be a `Weak` reference.
/// That's also the reason why it's being registered lazily instead of
/// during initialization.
pub fn register_transaction_pool(&self, pool: Weak<dyn sp_transaction_pool::OffchainSubmitTransaction<Block>>) {
*self.transaction_pool.write() = Some(pool);
pub fn register_transaction_pool<T>(&self, pool: &Arc<T>)
where T: sp_transaction_pool::OffchainSubmitTransaction<Block> + 'static
{
*self.transaction_pool.write() = Some(Arc::downgrade(&pool) as _);
}
/// Create `ExecutionManager` and `Extensions` for given offchain call.