Companion PR for Remove the service, replacing it with a struct of individual chain components (#1288)

* Switch branch

* Fix service things

* Fix browser node compilation

* Update branch

* fixed new service

* Update for new branch

* Fix browser node

* Update branch

* Revert "Switch branch"

This reverts commit 3623adff7681124a1539a385a718c34e85931254.

* Update cargo.lock

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Ashley
2020-06-30 14:06:55 +02:00
committed by GitHub
parent baadabd910
commit b26f6d08ac
7 changed files with 475 additions and 381 deletions
+47 -50
View File
@@ -19,8 +19,7 @@ use log::info;
use service::{IdentifyVariant, self};
#[cfg(feature = "service-rewr")]
use service_new::{IdentifyVariant, self as service};
use sc_executor::NativeExecutionDispatch;
use sc_cli::{SubstrateCli, Result};
use sc_cli::{SubstrateCli, Result, RuntimeVersion, Role};
use crate::cli::{Cli, Subcommand};
fn get_exec_name() -> Option<String> {
@@ -75,6 +74,16 @@ impl SubstrateCli for Cli {
path => Box::new(service::PolkadotChainSpec::from_json_file(std::path::PathBuf::from(path))?),
})
}
fn native_runtime_version(spec: &Box<dyn service::ChainSpec>) -> &'static RuntimeVersion {
if spec.is_kusama() {
&service::kusama_runtime::VERSION
} else if spec.is_westend() {
&service::westend_runtime::VERSION
} else {
&service::polkadot_runtime::VERSION
}
}
}
/// Parses polkadot specific CLI arguments and run the service.
@@ -116,56 +125,44 @@ pub fn run() -> Result<()> {
info!(" KUSAMA FOUNDATION ");
info!("----------------------------");
runtime.run_node(
|config| {
service::kusama_new_light(config)
},
|config| {
service::kusama_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::KusamaExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::kusama_new_light(config)
.map(|(components, _)| components),
_ => service::kusama_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
} else if chain_spec.is_westend() {
runtime.run_node(
|config| {
service::westend_new_light(config)
},
|config| {
service::westend_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::WestendExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::westend_new_light(config)
.map(|(components, _)| components),
_ => service::westend_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
} else {
runtime.run_node(
|config| {
service::polkadot_new_light(config)
},
|config| {
service::polkadot_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(s, _, _)| s)
},
service::PolkadotExecutor::native_version().runtime_version
)
runtime.run_node_until_exit(|config| match config.role {
Role::Light => service::polkadot_new_light(config)
.map(|(components, _)| components),
_ => service::polkadot_new_full(
config,
None,
None,
authority_discovery_enabled,
6000,
grandpa_pause,
).map(|(components, _, _)| components)
})
}
},
Some(Subcommand::Base(subcommand)) => {