From 6b6820e17334b48e72432fe670e10987fe07c66e Mon Sep 17 00:00:00 2001 From: Chevdor Date: Thu, 19 Jul 2018 11:26:52 +0200 Subject: [PATCH] Use generated name if no name was provided (#377) --- polkadot/cli/Cargo.toml | 1 + polkadot/cli/src/lib.rs | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/polkadot/cli/Cargo.toml b/polkadot/cli/Cargo.toml index b2bf91db90..fe25cb45c2 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 9ce9da8ea0..2552e36b42 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(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);