Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

expose substrate-cli service #10229

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn run() -> Result<()> {
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
service::new_full(config).map_err(sc_cli::Error::Service)
Ok(service::new_full(config).map_err(sc_cli::Error::Service)?.0)
})
},
Some(Subcommand::Inspect(cmd)) => {
Expand Down
12 changes: 7 additions & 5 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use sc_client_api::{BlockBackend, ExecutorProvider};
use sc_consensus_babe::{self, SlotProportion};
use sc_executor::NativeElseWasmExecutor;
use sc_network::{Event, NetworkService};
use sc_service::{config::Configuration, error::Error as ServiceError, TaskManager};
use sc_service::{config::Configuration, error::Error as ServiceError, TaskManager, RpcHandlers};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sp_api::ProvideRuntimeApi;
use sp_core::crypto::Pair;
Expand Down Expand Up @@ -298,6 +298,8 @@ pub struct NewFullBase {
pub network: Arc<NetworkService<Block, <Block as BlockT>::Hash>>,
/// The transaction pool of the node.
pub transaction_pool: Arc<TransactionPool>,
/// The rpc handlers of the node.
pub rpc_handlers: RpcHandlers,
}

/// Creates a full service from the configuration.
Expand Down Expand Up @@ -358,7 +360,7 @@ pub fn new_full_base(
let enable_grandpa = !config.disable_grandpa;
let prometheus_registry = config.prometheus_registry().cloned();

let _rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
let rpc_handlers = sc_service::spawn_tasks(sc_service::SpawnTasksParams {
config,
backend,
client: client.clone(),
Expand Down Expand Up @@ -507,12 +509,12 @@ pub fn new_full_base(
}

network_starter.start_network();
Ok(NewFullBase { task_manager, client, network, transaction_pool })
Ok(NewFullBase { task_manager, client, network, transaction_pool, rpc_handlers })
}

/// Builds a new service for a full client.
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
new_full_base(config, |_, _| ()).map(|NewFullBase { task_manager, .. }| task_manager)
pub fn new_full(config: Configuration) -> Result<(TaskManager, RpcHandlers), ServiceError> {
new_full_base(config, |_, _| ()).map(|NewFullBase { task_manager, rpc_handlers, .. }| (task_manager, rpc_handlers))
}
sander2 marked this conversation as resolved.
Show resolved Hide resolved

#[cfg(test)]
Expand Down