From 504b2de4a853119bb5efba1e456c47222b696764 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 11 Oct 2017 14:34:23 +0700 Subject: [PATCH 1/3] Migrating util/network from rust_serialize to serde (#5988) --- Cargo.lock | 1 + util/network/Cargo.toml | 1 + util/network/src/lib.rs | 2 +- util/network/src/node_table.rs | 6 +++--- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd46ffb95..6b6951202 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -811,6 +811,7 @@ dependencies = [ "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index ba34bfac7..19afb8130 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -34,6 +34,7 @@ path = { path = "../path" } ethcore-logger = { path ="../../logger" } ipnetwork = "0.12.6" hash = { path = "../hash" } +serde_json = "1.0" [features] default = [] diff --git a/util/network/src/lib.rs b/util/network/src/lib.rs index f23998984..6257118b6 100644 --- a/util/network/src/lib.rs +++ b/util/network/src/lib.rs @@ -69,7 +69,6 @@ extern crate rand; extern crate time; extern crate ansi_term; //TODO: remove this extern crate rustc_hex; -extern crate rustc_serialize; extern crate igd; extern crate libc; extern crate slab; @@ -81,6 +80,7 @@ extern crate path; extern crate ethcore_logger; extern crate ipnetwork; extern crate hash; +extern crate serde_json; #[macro_use] extern crate log; diff --git a/util/network/src/node_table.rs b/util/network/src/node_table.rs index 1225c750c..052657db6 100644 --- a/util/network/src/node_table.rs +++ b/util/network/src/node_table.rs @@ -32,7 +32,7 @@ use error::NetworkError; use {AllowIP, IpFilter}; use discovery::{TableUpdates, NodeEntry}; use ip_utils::*; -pub use rustc_serialize::json::Json; +use serde_json::Value; /// Node public key pub type NodeId = H512; @@ -332,7 +332,7 @@ impl NodeTable { return nodes; } } - let json = match Json::from_str(&buf) { + let json: Value = match ::serde_json::from_str(&buf) { Ok(json) => json, Err(e) => { warn!("Error parsing node table file: {:?}", e); @@ -341,7 +341,7 @@ impl NodeTable { }; if let Some(list) = json.as_object().and_then(|o| o.get("nodes")).and_then(|n| n.as_array()) { for n in list.iter().filter_map(|n| n.as_object()) { - if let Some(url) = n.get("url").and_then(|u| u.as_string()) { + if let Some(url) = n.get("url").and_then(|u| u.as_str()) { if let Ok(mut node) = Node::from_str(url) { if let Some(failures) = n.get("failures").and_then(|f| f.as_u64()) { node.failures = failures as u32; From 604cdde71d27ab36d4839a29444e0fd350d59ee7 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 11 Oct 2017 17:39:12 +0700 Subject: [PATCH 2/3] Fixes bench and removes rustc_serialize dependency (#5988) --- ethcore/benches/evm.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ethcore/benches/evm.rs b/ethcore/benches/evm.rs index 384aa60a6..324e3382e 100644 --- a/ethcore/benches/evm.rs +++ b/ethcore/benches/evm.rs @@ -21,8 +21,9 @@ extern crate ethcore_util as util; extern crate rand; extern crate bn; extern crate crypto; -extern crate rustc_serialize; extern crate ethkey; +extern crate rustc_hex; +extern crate ethcore_bigint; use self::test::{Bencher}; use rand::{StdRng}; @@ -75,9 +76,9 @@ fn sha256(b: &mut Bencher) { #[bench] fn ecrecover(b: &mut Bencher) { - use rustc_serialize::hex::FromHex; + use rustc_hex::FromHex; use ethkey::{Signature, recover as ec_recover}; - use util::H256; + use ethcore_bigint::hash::H256; let input = FromHex::from_hex("47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad000000000000000000000000000000000000000000000000000000000000001b650acf9d3f5f0a2c799776a1254355d5f4061762a237396a99a0e0e3fc2bcd6729514a0dacb2e623ac4abd157cb18163ff942280db4d5caad66ddf941ba12e03").unwrap(); let hash = H256::from_slice(&input[0..32]); let v = H256::from_slice(&input[32..64]); From 4f86f5b76d99338a7284a13196303a4e253ed5e9 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Wed, 11 Oct 2017 22:01:00 +0700 Subject: [PATCH 3/3] Removes rustc-serialize references from Cargo.toml and Cargo.lock --- Cargo.lock | 1 - util/network/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b6951202..78a8d472f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -810,7 +810,6 @@ dependencies = [ "rlp 0.2.0", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/util/network/Cargo.toml b/util/network/Cargo.toml index 19afb8130..e99df9024 100644 --- a/util/network/Cargo.toml +++ b/util/network/Cargo.toml @@ -21,7 +21,6 @@ libc = "0.2.7" parking_lot = "0.4" ansi_term = "0.9" rustc-hex = "1.0" -rustc-serialize = "0.3" ethcore-io = { path = "../io" } ethcore-util = { path = ".." } ethcore-bigint = { path = "../bigint" }