Add --chain option. (#122)

* Add --chain option.

* Reinstate bail on unknown runtime.
This commit is contained in:
Gav Wood
2018-04-12 13:15:56 +02:00
committed by GitHub
parent 1972d612fa
commit 46e3c32e49
7 changed files with 149 additions and 53 deletions
+5
View File
@@ -48,4 +48,9 @@ args:
help: Specify a list of bootnodes
takes_value: true
multiple: true
- chain:
long: chain
value_name: CHAIN_SPEC
help: Specify the chain specification (one of dev or poc-1)
takes_value: true
subcommands:
+12
View File
@@ -52,6 +52,7 @@ use std::net::SocketAddr;
use futures::sync::mpsc;
use futures::{Sink, Future, Stream};
use tokio_core::reactor;
use service::ChainSpec;
/// Parse command line arguments and start the node.
///
@@ -104,6 +105,17 @@ pub fn run<I, T>(args: I) -> error::Result<()> where
role = service::Role::VALIDATOR;
}
match matches.value_of("chain") {
Some("poc-1") => config.chain_spec = ChainSpec::PoC1Testnet,
Some("dev") => config.chain_spec = ChainSpec::Development,
None => (),
Some(unknown) => panic!("Invalid chain name: {}", unknown),
}
info!("Chain specification: {}", match config.chain_spec {
ChainSpec::Development => "Local Development",
ChainSpec::PoC1Testnet => "PoC-1 Testnet",
});
config.roles = role;
config.network.boot_nodes = matches
.values_of("bootnodes")