Split the service initialisation up into seperate functions (#6332)

* Seperate out the complexity in ServiceBuilder::build_common into seperate functions

* Fix line widths

* Move some functions to their respective crates
This commit is contained in:
Ashley
2020-06-16 15:50:21 +02:00
committed by GitHub
parent c44947bbcb
commit 761dbd7dcc
19 changed files with 452 additions and 330 deletions
@@ -683,3 +683,23 @@ impl<PoolApi, Block> MaintainedTransactionPool for BasicPool<PoolApi, Block>
}
}
}
/// Inform the transaction pool about imported and finalized blocks.
pub async fn notification_future<Client, Pool, Block>(
client: Arc<Client>,
txpool: Arc<Pool>
)
where
Block: BlockT,
Client: sc_client_api::BlockchainEvents<Block>,
Pool: MaintainedTransactionPool<Block=Block>,
{
let import_stream = client.import_notification_stream().map(Into::into).fuse();
let finality_stream = client.finality_notification_stream()
.map(Into::into)
.fuse();
futures::stream::select(import_stream, finality_stream)
.for_each(|evt| txpool.maintain(evt))
.await
}