From 63bbd0ccd8b592bc8260ed41e8d558848ebdc088 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 21 Feb 2016 20:00:45 +0100 Subject: [PATCH] Use proper version string. --- Cargo.lock | 2 ++ parity/main.rs | 7 +++---- rpc/Cargo.toml | 1 + rpc/src/lib.rs | 1 - rpc/src/v1/impls/web3.rs | 6 ++++-- util/Cargo.toml | 1 + util/src/lib.rs | 1 + util/src/misc.rs | 7 +++++++ util/src/network/host.rs | 4 ++-- 9 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 259a0c4d8..acdb241ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,6 +204,7 @@ dependencies = [ "jsonrpc-core 1.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -234,6 +235,7 @@ dependencies = [ "rocksdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rust-crypto 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.1.0", "slab 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/parity/main.rs b/parity/main.rs index 58d3a6f4c..f4b7880ab 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -29,7 +29,6 @@ extern crate log as rlog; extern crate env_logger; extern crate ctrlc; extern crate fdlimit; -extern crate target_info; extern crate daemonize; #[cfg(feature = "rpc")] @@ -51,7 +50,6 @@ use ethcore::ethereum; use ethcore::blockchain::CacheSize; use ethsync::EthSync; use docopt::Docopt; -use target_info::Target; use daemonize::Daemonize; const USAGE: &'static str = " @@ -146,14 +144,15 @@ fn setup_rpc_server(_client: Arc, _sync: Arc, _url: &str) { fn print_version() { println!("\ -Parity version {} ({}-{}-{}) +Parity + version {} Copyright 2015, 2016 Ethcore (UK) Limited License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. By Wood/Paronyan/Kotewicz/Drwięga/Volf.\ -", env!("CARGO_PKG_VERSION"), Target::arch(), Target::env(), Target::os()); +", version()); } fn die_with_message(msg: &str) -> ! { diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 0b7c17383..bce5b609c 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -20,6 +20,7 @@ clippy = { version = "0.0.42", optional = true } target_info = "0.1.0" rustc-serialize = "0.3" serde_macros = { version = "0.6.13", optional = true } +rustc_version = "0.1.0" [build-dependencies] serde_codegen = { version = "0.6.13", optional = true } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index c9542ade7..d7b5bdc3b 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -20,7 +20,6 @@ #![cfg_attr(nightly, plugin(serde_macros, clippy))] extern crate rustc_serialize; -extern crate target_info; extern crate serde; extern crate serde_json; extern crate jsonrpc_core; diff --git a/rpc/src/v1/impls/web3.rs b/rpc/src/v1/impls/web3.rs index f10150a30..0a237d56b 100644 --- a/rpc/src/v1/impls/web3.rs +++ b/rpc/src/v1/impls/web3.rs @@ -15,8 +15,8 @@ // along with Parity. If not, see . //! Web3 rpc implementation. -use target_info::Target; use jsonrpc_core::*; +use util::version; use v1::traits::Web3; /// Web3 rpc implementation. @@ -30,7 +30,9 @@ impl Web3Client { impl Web3 for Web3Client { fn client_version(&self, params: Params) -> Result { match params { - Params::None => Ok(Value::String(format!("Parity/-/{}/{}-{}-{}/rust1.8-nightly", env!("CARGO_PKG_VERSION"), Target::arch(), Target::env(), Target::os()))), + Params::None => { + Ok(Value::String(version())), + } _ => Err(Error::invalid_params()) } } diff --git a/util/Cargo.toml b/util/Cargo.toml index 5d7fa697f..29d820760 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -29,6 +29,7 @@ serde = "0.6.7" clippy = { version = "0.0.42", optional = true } json-tests = { path = "json-tests" } target_info = "0.1.0" +rustc_version = "0.1.0" igd = "0.4.2" ethcore-devtools = { path = "../devtools" } libc = "0.2.7" diff --git a/util/src/lib.rs b/util/src/lib.rs index 9527341ad..b91e2d65b 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -108,6 +108,7 @@ extern crate log as rlog; extern crate igd; extern crate ethcore_devtools as devtools; extern crate libc; +extern crate rustc_version; pub mod standard; #[macro_use] diff --git a/util/src/misc.rs b/util/src/misc.rs index ae3dbc5bf..fdbaa0b49 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -18,6 +18,8 @@ use std::fs::File; use common::*; +use target_info::Target; +use rustc_version; #[derive(Debug,Clone,PartialEq,Eq)] /// Diff type for specifying a change (or not). @@ -62,3 +64,8 @@ pub fn contents(name: &str) -> Result { try!(file.read_to_end(&mut ret)); Ok(ret) } + +/// Get the standard version string for this software. +pub fn version() -> String { + format!("Parity/-/{}/{}-{}-{}/{}", env!("CARGO_PKG_VERSION"), Target::arch(), Target::env(), Target::os(), rustc_version::version()) +} \ No newline at end of file diff --git a/util/src/network/host.rs b/util/src/network/host.rs index 326cd2715..fb3150ad3 100644 --- a/util/src/network/host.rs +++ b/util/src/network/host.rs @@ -26,8 +26,8 @@ use std::io::{Read, Write}; use std::fs; use mio::*; use mio::tcp::*; -use target_info::Target; use hash::*; +use misc::version; use crypto::*; use sha3::Hashable; use rlp::*; @@ -360,7 +360,7 @@ impl Host where Message: Send + Sync + Clone { config: config, nonce: H256::random(), protocol_version: PROTOCOL_VERSION, - client_version: format!("Parity/{}/{}-{}-{}", env!("CARGO_PKG_VERSION"), Target::arch(), Target::env(), Target::os()), + client_version: version(), listen_port: 0, capabilities: Vec::new(), }),