mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 04:28:01 +00:00
Splitting relaychain and parachain command-line arguments (#42)
Fixes #34 Added .editorconfig
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
root = true
|
||||
[*]
|
||||
indent_style=tab
|
||||
indent_size=tab
|
||||
tab_width=4
|
||||
end_of_line=lf
|
||||
charset=utf-8
|
||||
trim_trailing_whitespace=true
|
||||
max_line_length=100
|
||||
insert_final_newline=true
|
||||
Generated
+491
-493
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,7 @@ trie-root = '0.15.2'
|
||||
codec = { package = 'parity-scale-codec', version = '1.0.0' }
|
||||
structopt = "0.3.3"
|
||||
ctrlc = { version = "3.1.3", features = ["termination"] }
|
||||
itertools = { version = "0.8.2" }
|
||||
|
||||
# Parachain dependencies
|
||||
parachain-runtime = { package = "cumulus-test-parachain-runtime", path = "runtime" }
|
||||
|
||||
+24
-10
@@ -30,6 +30,8 @@ use sp_runtime::{
|
||||
traits::{Block as BlockT, Hash as HashT, Header as HeaderT},
|
||||
BuildStorage,
|
||||
};
|
||||
use polkadot_service::ChainSpec as ChainSpecPolkadot;
|
||||
use polkadot_service::CustomConfiguration as CustomConfigurationPolkadot;
|
||||
|
||||
use futures::{channel::oneshot, future::Map, FutureExt};
|
||||
|
||||
@@ -64,17 +66,18 @@ struct ExportGenesisStateCommand {
|
||||
}
|
||||
|
||||
/// Parse command line arguments into service configuration.
|
||||
pub fn run<I, T, E>(args: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||
pub fn run<I, T, E>(args_parachain: I, args_relaychain: I, exit: E, version: VersionInfo) -> error::Result<()>
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
T: Into<std::ffi::OsString> + Clone,
|
||||
E: IntoExit + Send + 'static,
|
||||
{
|
||||
type Config<T> = Configuration<(), T>;
|
||||
|
||||
match parse_and_prepare::<SubCommands, NoCustom, _>(
|
||||
&version,
|
||||
"cumulus-test-parachain-collator",
|
||||
args,
|
||||
args_parachain,
|
||||
) {
|
||||
ParseAndPrepare::Run(cmd) => cmd.run(
|
||||
load_spec,
|
||||
@@ -94,14 +97,19 @@ where
|
||||
// TODO
|
||||
config.network.listen_addresses = Vec::new();
|
||||
|
||||
// TODO
|
||||
let mut polkadot_config =
|
||||
polkadot_collator::Configuration::default_with_spec_and_base_path(
|
||||
polkadot_service::ChainSpec::from_json_bytes(
|
||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||
)?,
|
||||
config.in_chain_config_dir("polkadot"),
|
||||
);
|
||||
let mut polkadot_config = parse_and_prepare::<NoCustom, NoCustom, _>(
|
||||
&version,
|
||||
"cumulus-test-parachain-collator",
|
||||
args_relaychain,
|
||||
).into_configuration::<CustomConfigurationPolkadot, _, _, _>(
|
||||
load_spec_polkadot,
|
||||
config.in_chain_config_dir("polkadot"),
|
||||
)
|
||||
.map_err(|e| e.to_string())?
|
||||
.expect(
|
||||
"can only fail when this is a CustomCommand. Running parse_and_prepare with \
|
||||
NoCustom can never return a CustomCommand; therefore this will never fail; qed"
|
||||
);
|
||||
polkadot_config.network.boot_nodes = config.network.boot_nodes.clone();
|
||||
|
||||
if let Some(ref config_dir) = polkadot_config.config_dir {
|
||||
@@ -155,6 +163,12 @@ fn load_spec(_: &str) -> std::result::Result<Option<chain_spec::ChainSpec>, Stri
|
||||
Ok(Some(chain_spec::get_chain_spec()))
|
||||
}
|
||||
|
||||
fn load_spec_polkadot(_: &str) -> std::result::Result<Option<ChainSpecPolkadot>, String> {
|
||||
Some(polkadot_service::ChainSpec::from_json_bytes(
|
||||
&include_bytes!("../res/polkadot_chainspec.json")[..],
|
||||
)).transpose()
|
||||
}
|
||||
|
||||
/// Export the genesis state of the parachain.
|
||||
fn export_genesis_state(output: Option<PathBuf>) -> error::Result<()> {
|
||||
let storage = (&chain_spec::get_chain_spec()).build_storage()?;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#![warn(missing_docs)]
|
||||
#![warn(unused_extern_crates)]
|
||||
|
||||
use itertools::Itertools;
|
||||
use polkadot_primitives::parachain::Id as ParaId;
|
||||
|
||||
mod chain_spec;
|
||||
@@ -30,17 +31,28 @@ pub use sc_cli::{error, IntoExit, VersionInfo};
|
||||
|
||||
/// The parachain id of this parachain.
|
||||
pub const PARA_ID: ParaId = ParaId::new(100);
|
||||
const EXECUTABLE_NAME: &'static str = "cumulus-test-parachain-collator";
|
||||
const DESCRIPTION: &'static str =
|
||||
"Cumulus test parachain collator\n\nThe command-line arguments provided first will be \
|
||||
passed to the parachain node, while the arguments provided after -- will be passed \
|
||||
to the relaychain node.\n\n\
|
||||
cumulus-test-parachain-collator [parachain-args] -- [relaychain-args]";
|
||||
|
||||
fn main() -> Result<(), cli::error::Error> {
|
||||
let version = VersionInfo {
|
||||
name: "Cumulus Test Parachain Collator",
|
||||
commit: env!("VERGEN_SHA_SHORT"),
|
||||
version: env!("CARGO_PKG_VERSION"),
|
||||
executable_name: "cumulus-test-parachain-collator",
|
||||
author: "Parity Technologies <admin@parity.io>",
|
||||
description: "Cumulus test parachain collator",
|
||||
description: DESCRIPTION,
|
||||
executable_name: EXECUTABLE_NAME,
|
||||
support_url: "https://github.com/paritytech/cumulus/issues/new",
|
||||
};
|
||||
|
||||
cli::run(std::env::args(), cli::Exit, version)
|
||||
let args = std::env::args().collect::<Vec<String>>();
|
||||
let mut iter = args.iter();
|
||||
let parachain_args: Vec<_> = iter.take_while_ref(|&x| x != &"--").collect();
|
||||
let relaychain_args: Vec<_> = iter.collect();
|
||||
|
||||
cli::run(parachain_args, relaychain_args, cli::Exit, version)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user