Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5178a3f
WIP
expenses Jun 12, 2020
9bb0129
Making progress
expenses Jun 15, 2020
91767ac
Almost ready
expenses Jun 15, 2020
3de5fce
Get service tests compiling
expenses Jun 16, 2020
937ad16
Fix node screenshot
expenses Jun 16, 2020
8d84167
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 16, 2020
30b8c65
Line widths
expenses Jun 18, 2020
a09301e
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 18, 2020
5bcf9f6
Fix node cli tests
expenses Jun 18, 2020
01e3ea0
Fix node cli warning
expenses Jun 18, 2020
1290452
ChainComponents -> ServiceComponents, fix tests
expenses Jun 18, 2020
11e3203
make spawn_handle public
expenses Jun 19, 2020
04d82e1
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 22, 2020
55df8af
Remove spawnnamed impl for taskmanager
expenses Jun 22, 2020
4e11e59
Move the keep alive stuff to the task manager
expenses Jun 23, 2020
22048cf
Move the telemetry, base path, rpc keep_alive to the service builder
expenses Jun 23, 2020
b5b335a
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 23, 2020
8ae7a04
Make the task manager keep alive an internal detail
expenses Jun 24, 2020
3319c11
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 24, 2020
f0a8f35
Rewrite the browser start_client future
expenses Jun 24, 2020
4546435
Remove run_node etc
expenses Jun 24, 2020
f42df6c
Revert my personal changes to browser-demo/build.sh
expenses Jun 24, 2020
0ad4e40
use |config|
expenses Jun 24, 2020
d066c02
Add a runtime_version function to SubstrateCli
expenses Jun 24, 2020
1305100
Reexport role and runtime version from sc cli
expenses Jun 24, 2020
1326a02
Update Cargo.lock
expenses Jun 24, 2020
772b757
runtime_version -> native_runtime_version
expenses Jun 25, 2020
efae0da
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 25, 2020
fe9d37a
Pass chain spec to native_runtime_version for polkadot
expenses Jun 25, 2020
97112f2
Merge remote-tracking branch 'parity/master' into ashley-service-mult…
expenses Jun 29, 2020
9c2e782
Fix line widths
expenses Jun 29, 2020
1f71076
Traitify ServiceComponents Client
expenses Jun 30, 2020
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
Prev Previous commit
Next Next commit
Remove run_node etc
  • Loading branch information
expenses committed Jun 24, 2020
commit 45464353064b86c7844d9959bcd6f7e9c3448eda
12 changes: 7 additions & 5 deletions bin/node-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use sc_cli::SubstrateCli;
use sc_service::Role;

impl SubstrateCli for Cli {
fn impl_name() -> &'static str {
Expand Down Expand Up @@ -71,11 +72,12 @@ pub fn run() -> sc_cli::Result<()> {
}
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node(
service::new_light,
service::new_full,
node_template_runtime::VERSION
)
runner.print_node_infos(node_template_runtime::VERSION);
let service_fn = match runner.config().role {
Role::Light => service::new_light,
_ => service::new_full,
};
runner.run_node_until_exit(service_fn)
}
}
}
12 changes: 7 additions & 5 deletions bin/node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::{chain_spec, service, Cli, Subcommand};
use node_executor::Executor;
use node_runtime::{Block, RuntimeApi};
use sc_cli::{Result, SubstrateCli};
use sc_service::Role;

impl SubstrateCli for Cli {
fn impl_name() -> &'static str {
Expand Down Expand Up @@ -70,11 +71,12 @@ pub fn run() -> Result<()> {
match &cli.subcommand {
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node(
service::new_light,
service::new_full,
node_runtime::VERSION
)
runner.print_node_infos(node_runtime::VERSION);
let service_fn = match runner.config().role {
Role::Light => service::new_light,
_ => service::new_full,
};
runner.run_node_until_exit(service_fn)
}
Some(Subcommand::Inspect(cmd)) => {
let runner = cli.create_runner(cmd)?;
Expand Down
53 changes: 4 additions & 49 deletions client/cli/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use futures::pin_mut;
use futures::select;
use futures::{future, future::FutureExt, Future};
use log::info;
use sc_service::{Configuration, Role, ServiceBuilderCommand, TaskType, TaskManager};
use sc_service::{Configuration, ServiceBuilderCommand, TaskType, TaskManager};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use sp_utils::metrics::{TOKIO_THREADS_ALIVE, TOKIO_THREADS_TOTAL};
use sp_version::RuntimeVersion;
Expand Down Expand Up @@ -172,53 +172,6 @@ impl<C: SubstrateCli> Runner<C> {
info!("⛓ Native runtime: {}", runtime_version);
}

/// A helper function that runs a node with tokio and stops if the process
/// receives the signal `SIGTERM` or `SIGINT`. It can run a full or a light node depending on
/// the node's configuration.
pub fn run_node(
self,
new_light: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
new_full: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
runtime_version: RuntimeVersion,
) -> Result<()> {
match self.config.role {
Role::Light => self.run_light_node(new_light, runtime_version),
_ => self.run_full_node(new_full, runtime_version),
}
}

/// A helper function that runs a node with tokio and stops if the process
/// receives the signal `SIGTERM` or `SIGINT`. It can only run a "full" node and will fail if
/// the node's configuration uses a "light" role.
pub fn run_full_node(
self,
new_full: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
runtime_version: RuntimeVersion,
) -> Result<()> {
if matches!(self.config.role, Role::Light) {
return Err("Light node has been requested but this is not implemented".into());
}

self.print_node_infos(runtime_version);
self.run_service_until_exit(new_full)
}

/// A helper function that runs a node with tokio and stops if the process
/// receives the signal `SIGTERM` or `SIGINT`. It can only run a "light" node and will fail if
/// the node's configuration uses a "full" role.
pub fn run_light_node(
self,
new_light: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
runtime_version: RuntimeVersion,
) -> Result<()> {
if !matches!(self.config.role, Role::Light) {
return Err("Full node has been requested but this is not implemented".into());
}

self.print_node_infos(runtime_version);
self.run_service_until_exit(new_light)
}

/// A helper function that runs a future with tokio and stops if the process receives the signal
/// `SIGTERM` or `SIGINT`.
pub fn run_subcommand<B, BC, BB>(self, subcommand: &Subcommand, builder: B) -> Result<()>
Expand Down Expand Up @@ -247,7 +200,9 @@ impl<C: SubstrateCli> Runner<C> {
}
}

fn run_service_until_exit(
/// A helper function that runs a node with tokio and stops if the process receives the signal
/// `SIGTERM` or `SIGINT`.
pub fn run_node_until_exit(
mut self,
initialise: impl FnOnce(Configuration) -> sc_service::error::Result<TaskManager>,
) -> Result<()> {
Expand Down