diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index b2bf91db90546e3636b03b4dbeeb1a2bc1b33a5d..fe25cb45c2928932790045a6e267eb95ac91bed8 100644 --- a/polkadot/cli/Cargo.toml +++ b/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/polkadot/cli/src/lib.rs b/polkadot/cli/src/lib.rs index 9ce9da8ea0422506f2e37484b573e5c65bec1576..2552e36b42ddf6474c9a093fbbb6d9e967ec6f59 100644 --- a/polkadot/cli/src/lib.rs +++ b/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<I, T, W>(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);