From a66b45f47e21040bacf132d001b5c1f5533011db Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Thu, 1 Feb 2024 10:46:59 +0200 Subject: [PATCH 1/3] Expose internal functions used by `spawn_tasks` --- substrate/client/service/src/builder.rs | 10 ++++++---- substrate/client/service/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index bc848e8d4b29..7bfae1cf3bc8 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,7 @@ where Ok(rpc_handlers) } -async fn transaction_notifications( +pub async fn propagate_transaction_notifications( transaction_pool: Arc, tx_handler_controller: sc_network_transactions::TransactionsHandlerController< ::Hash, @@ -560,7 +560,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 +599,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 875cb9ca79e2..a76e1544bfbb 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>, From 2551ec231e9f05723a21c011a483e4cc721ef342 Mon Sep 17 00:00:00 2001 From: Nazar Mokrynskyi Date: Thu, 1 Feb 2024 10:57:34 +0200 Subject: [PATCH 2/3] Add prdoc --- prdoc/pr_3166.prdoc | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 prdoc/pr_3166.prdoc diff --git a/prdoc/pr_3166.prdoc b/prdoc/pr_3166.prdoc new file mode 100644 index 000000000000..adf7f50e4e96 --- /dev/null +++ b/prdoc/pr_3166.prdoc @@ -0,0 +1,9 @@ +title: Expose internal functions used by `spawn_tasks` + +doc: + - audience: Node Dev + description: | + This allows to build a custom version of `spawn_tasks` with less copy-paste required + +crates: + - name: sc-service From 86cabf4215fe989472f48762475498611a109a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Fri, 2 Feb 2024 21:19:52 +0100 Subject: [PATCH 3/3] Apply suggestions from code review --- substrate/client/service/src/builder.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/substrate/client/service/src/builder.rs b/substrate/client/service/src/builder.rs index 7bfae1cf3bc8..31d63c6a81d3 100644 --- a/substrate/client/service/src/builder.rs +++ b/substrate/client/service/src/builder.rs @@ -532,6 +532,7 @@ where Ok(rpc_handlers) } +/// 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<