diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index d325c991fe..52f332c939 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -1594,6 +1594,14 @@ dependencies = [ "varint 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=727e0e099b53a4032a7e2330994c819fe866add7)", ] +[[package]] +name = "names" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nan-preserving-float" version = "0.1.0" @@ -1844,6 +1852,7 @@ dependencies = [ "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "polkadot-primitives 0.1.0", "polkadot-runtime 0.1.0", @@ -2703,7 +2712,7 @@ dependencies = [ "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.70 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.64 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4017,6 +4026,7 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum multiaddr 0.3.0 (git+https://github.com/tomaka/libp2p-rs?rev=727e0e099b53a4032a7e2330994c819fe866add7)" = "" "checksum multibase 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b9c35dac080fd6e16a99924c8dfdef0af89d797dd851adab25feaffacf7850d6" +"checksum names 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ef320dab323286b50fb5cdda23f61c796a72a89998ab565ca32525c5c556f2da" "checksum multihash 0.8.1-pre (git+https://github.com/tomaka/libp2p-rs?rev=727e0e099b53a4032a7e2330994c819fe866add7)" = "" "checksum multistream-select 0.1.0 (git+https://github.com/tomaka/libp2p-rs?rev=727e0e099b53a4032a7e2330994c819fe866add7)" = "" "checksum nan-preserving-float 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d4f00fcc2f4c9efa8cc971db0da9e28290e28e97af47585e48691ef10ff31f" diff --git a/substrate/polkadot/cli/Cargo.toml b/substrate/polkadot/cli/Cargo.toml index b2bf91db90..fe25cb45c2 100644 --- a/substrate/polkadot/cli/Cargo.toml +++ b/substrate/polkadot/cli/Cargo.toml @@ -40,3 +40,4 @@ polkadot-primitives = { path = "../primitives" } polkadot-runtime = { path = "../runtime" } polkadot-service = { path = "../service" } polkadot-transaction-pool = { path = "../transaction-pool" } +names = "0.11.0" diff --git a/substrate/polkadot/cli/src/lib.rs b/substrate/polkadot/cli/src/lib.rs index 9ce9da8ea0..2552e36b42 100644 --- a/substrate/polkadot/cli/src/lib.rs +++ b/substrate/polkadot/cli/src/lib.rs @@ -32,6 +32,7 @@ extern crate triehash; extern crate parking_lot; extern crate serde; extern crate serde_json; +extern crate names; extern crate substrate_client as client; extern crate substrate_network as network; @@ -82,6 +83,7 @@ use polkadot_primitives::BlockId; use codec::{Decode, Encode}; use client::BlockOrigin; use runtime_primitives::generic::SignedBlock; +use names::{Generator, Name}; use futures::Future; use tokio::runtime::Runtime; @@ -199,10 +201,11 @@ pub fn run(args: I, worker: W) -> error::Result<()> where let (spec, is_global) = load_spec(&matches)?; let mut config = service::Configuration::default_with_spec(spec); - if let Some(name) = matches.value_of("name") { - config.name = name.into(); - info!("Node name: {}", config.name); - } + config.name = match matches.value_of("name") { + None => Generator::with_naming(Name::Numbered).next().unwrap(), + Some(name) => name.into(), + }; + info!("Node name: {}", config.name); let base_path = base_path(&matches);