From 7ced14490edb78a3e8e4136d43e7e211915a0a4f Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Wed, 31 May 2023 18:27:06 +0400 Subject: [PATCH] Expose `build_system_rpc_future` and `TransactionPoolAdapator` in sc-service (#14238) * Make block sync service customizable This change allows user to have their own network block logic, for example, we'd like to disable the builtin block sync service when using another syncing approach. * Remove unnecessary Box * Revert network_block * Expose build_system_rpc_future() and TransactionPoolAdaptor * fmt --- client/service/src/builder.rs | 1 + client/service/src/lib.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index a769a8eb6835..d2c045416626 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -713,6 +713,7 @@ pub struct BuildNetworkParams<'a, TBl: BlockT, TExPool, TImpQu, TCl> { /// block request handler will be used. pub block_relay: Option>, } + /// Build the network service, the network status sinks and an RPC sender. pub fn build_network( params: BuildNetworkParams, diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 54f11ec25a02..f7f795a5fd15 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -211,7 +211,7 @@ async fn build_network_future< } /// Builds a future that processes system RPC requests. -async fn build_system_rpc_future< +pub async fn build_system_rpc_future< B: BlockT, C: BlockchainEvents + HeaderBackend @@ -441,6 +441,13 @@ pub struct TransactionPoolAdapter { client: Arc, } +impl TransactionPoolAdapter { + /// Constructs a new instance of [`TransactionPoolAdapter`]. + pub fn new(pool: Arc

, client: Arc) -> Self { + Self { pool, client } + } +} + /// Get transactions for propagation. /// /// Function extracted to simplify the test and prevent creating `ServiceFactory`.