From 2fab0cbda5fc87a9284fb6031cd01d9d23d0b31e Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Sat, 3 Feb 2024 22:47:05 +0200 Subject: [PATCH] Expose internal functions used by `spawn_tasks` (#3166) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to build a custom version of `spawn_tasks` with less copy-paste required. Resolves https://github.com/paritytech/polkadot-sdk/issues/2110 --------- Co-authored-by: Bastian Köcher --- substrate/client/service/src/builder.rs | 11 +++++++---- substrate/client/service/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index bc848e8d4b293..31d63c6a81d3a 100644 --- a/substrate/client/service/src/builder.rs +++ b/substrate/client/service/src/builder.rs @@ -460,7 +460,7 @@ where spawn_handle.spawn( "on-transaction-imported", Some("transaction-pool"), - transaction_notifications( + propagate_transaction_notifications( transaction_pool.clone(), tx_handler_controller, telemetry.clone(), @@ -532,7 +532,8 @@ where Ok(rpc_handlers) } -async fn transaction_notifications( +/// Returns a future that forwards imported transactions to the transaction networking protocol. +pub async fn propagate_transaction_notifications( transaction_pool: Arc, tx_handler_controller: sc_network_transactions::TransactionsHandlerController< ::Hash, @@ -560,7 +561,8 @@ async fn transaction_notifications( .await; } -fn init_telemetry( +/// Initialize telemetry with provided configuration and return telemetry handle +pub fn init_telemetry( config: &mut Configuration, network: Network, client: Arc, @@ -598,7 +600,8 @@ where Ok(telemetry.handle()) } -fn gen_rpc_module( +/// Generate RPC module using provided configuration +pub fn gen_rpc_module( deny_unsafe: DenyUnsafe, spawn_handle: SpawnTaskHandle, client: Arc, diff --git a/substrate/client/service/src/lib.rs b/substrate/client/service/src/lib.rs index 875cb9ca79e20..a76e1544bfbb9 100644 --- a/substrate/client/service/src/lib.rs +++ b/substrate/client/service/src/lib.rs @@ -368,7 +368,7 @@ mod waiting { } /// Starts RPC servers. -fn start_rpc_servers( +pub fn start_rpc_servers( config: &Configuration, gen_rpc_module: R, rpc_id_provider: Option>,