Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Removed ethcore-util dependency from ethcore-network #7180

Merged
merged 2 commits into from Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ethcore/Cargo.toml
Expand Up @@ -54,7 +54,7 @@ kvdb = { path = "../util/kvdb" }
kvdb-rocksdb = { path = "../util/kvdb-rocksdb" }
kvdb-memorydb = { path = "../util/kvdb-memorydb" }
util-error = { path = "../util/error" }
snappy = { path = "../util/snappy" }
snappy = { git = "https://github.com/paritytech/rust-snappy" }
migration = { path = "../util/migration" }
macros = { path = "../util/macros" }
rust-crypto = "0.2.34"
Expand Down
3 changes: 2 additions & 1 deletion parity/configuration.rs
Expand Up @@ -25,7 +25,7 @@ use cli::{Args, ArgsError};
use hash::keccak;
use bigint::prelude::U256;
use bigint::hash::H256;
use util::{version_data, Address};
use util::{version_data, Address, version};
use bytes::Bytes;
use ansi_term::Colour;
use ethsync::{NetworkConfiguration, validate_node_url, self};
Expand Down Expand Up @@ -751,6 +751,7 @@ impl Configuration {
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
ret.reserved_nodes = self.init_reserved_nodes()?;
ret.allow_non_reserved = !self.args.flag_reserved_only;
ret.client_version = version();
Ok(ret)
}

Expand Down
1 change: 1 addition & 0 deletions parity/helpers.rs
Expand Up @@ -213,6 +213,7 @@ pub fn default_network_config() -> ::ethsync::NetworkConfiguration {
ip_filter: IpFilter::default(),
reserved_nodes: Vec::new(),
allow_non_reserved: true,
client_version: ::util::version(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions sync/src/api.rs
Expand Up @@ -546,6 +546,8 @@ pub struct NetworkConfiguration {
pub allow_non_reserved: bool,
/// IP Filtering
pub ip_filter: IpFilter,
/// Client version string
pub client_version: String,
}

impl NetworkConfiguration {
Expand Down Expand Up @@ -578,6 +580,7 @@ impl NetworkConfiguration {
reserved_nodes: self.reserved_nodes,
ip_filter: self.ip_filter,
non_reserved_mode: if self.allow_non_reserved { NonReservedPeerMode::Accept } else { NonReservedPeerMode::Deny },
client_version: self.client_version,
})
}
}
Expand All @@ -601,6 +604,7 @@ impl From<BasicNetworkConfiguration> for NetworkConfiguration {
reserved_nodes: other.reserved_nodes,
ip_filter: other.ip_filter,
allow_non_reserved: match other.non_reserved_mode { NonReservedPeerMode::Accept => true, _ => false } ,
client_version: other.client_version,
}
}
}
Expand Down
1 change: 0 additions & 1 deletion util/Cargo.toml
Expand Up @@ -11,7 +11,6 @@ build = "build.rs"
log = "0.3"
env_logger = "0.4"
rustc-hex = "1.0"
rocksdb = { git = "https://github.com/paritytech/rust-rocksdb" }
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
elastic-array = "0.9"
rlp = { path = "rlp" }
Expand Down
3 changes: 1 addition & 2 deletions util/network/Cargo.toml
Expand Up @@ -22,7 +22,6 @@ parking_lot = "0.4"
ansi_term = "0.9"
rustc-hex = "1.0"
ethcore-io = { path = "../io" }
ethcore-util = { path = ".." }
ethcore-bigint = { path = "../bigint" }
ethcore-bytes = { path = "../bytes" }
ethkey = { path = "../../ethkey" }
Expand All @@ -32,7 +31,7 @@ path = { path = "../path" }
ethcore-logger = { path ="../../logger" }
ipnetwork = "0.12.6"
keccak-hash = { path = "../hash" }
snappy = { path = "../snappy" }
snappy = { git = "https://github.com/paritytech/rust-snappy" }
serde_json = "1.0"
error-chain = { version = "0.11", default-features = false }

Expand Down
15 changes: 7 additions & 8 deletions util/network/src/host.rs
Expand Up @@ -30,7 +30,6 @@ use mio::*;
use mio::deprecated::{EventLoop};
use mio::tcp::*;
use bigint::hash::*;
use util::version;
use rlp::*;
use session::{Session, SessionInfo, SessionData};
use io::*;
Expand Down Expand Up @@ -108,6 +107,8 @@ pub struct NetworkConfiguration {
pub non_reserved_mode: NonReservedPeerMode,
/// IP filter
pub ip_filter: IpFilter,
/// Client identifier
pub client_version: String,
}

impl Default for NetworkConfiguration {
Expand Down Expand Up @@ -136,6 +137,7 @@ impl NetworkConfiguration {
ip_filter: IpFilter::default(),
reserved_nodes: Vec::new(),
non_reserved_mode: NonReservedPeerMode::Accept,
client_version: "Parity-network".into(),
}
}

Expand Down Expand Up @@ -331,8 +333,6 @@ pub struct HostInfo {
nonce: H256,
/// RLPx protocol version
pub protocol_version: u32,
/// Client identifier
pub client_version: String,
/// Registered capabilities (handlers)
pub capabilities: Vec<CapabilityInfo>,
/// Local address + discovery port
Expand All @@ -357,6 +357,10 @@ impl HostInfo {
self.nonce = keccak(&self.nonce);
self.nonce
}

pub fn client_version(&self) -> &str {
&self.config.client_version
}
}

type SharedSession = Arc<Mutex<Session>>;
Expand Down Expand Up @@ -423,7 +427,6 @@ impl Host {
config: config,
nonce: H256::random(),
protocol_version: PROTOCOL_VERSION,
client_version: version(),
capabilities: Vec::new(),
public_endpoint: None,
local_endpoint: local_endpoint,
Expand Down Expand Up @@ -519,10 +522,6 @@ impl Host {
Ok(())
}

pub fn client_version() -> String {
version()
}

pub fn external_url(&self) -> Option<String> {
let info = self.info.read();
info.public_endpoint.as_ref().map(|e| format!("{}", Node::new(info.id().clone(), e.clone())))
Expand Down
1 change: 0 additions & 1 deletion util/network/src/lib.rs
Expand Up @@ -59,7 +59,6 @@
#![recursion_limit="128"]

extern crate ethcore_io as io;
extern crate ethcore_util as util;
extern crate ethcore_bigint as bigint;
extern crate ethcore_bytes;
extern crate parking_lot;
Expand Down
3 changes: 1 addition & 2 deletions util/network/src/service.rs
Expand Up @@ -59,10 +59,9 @@ impl NetworkService {
let io_service = IoService::<NetworkIoMessage>::start()?;

let stats = Arc::new(NetworkStats::new());
let host_info = Host::client_version();
Ok(NetworkService {
io_service: io_service,
host_info: host_info,
host_info: config.client_version.clone(),
stats: stats,
host: RwLock::new(None),
config: config,
Expand Down
2 changes: 1 addition & 1 deletion util/network/src/session.rs
Expand Up @@ -489,7 +489,7 @@ impl Session {
rlp.append_raw(&[PACKET_HELLO as u8], 0);
rlp.begin_list(5)
.append(&host.protocol_version)
.append(&host.client_version)
.append(&host.client_version())
.append_list(&host.capabilities)
.append(&host.local_endpoint.address.port())
.append(host.id());
Expand Down
8 changes: 0 additions & 8 deletions util/snappy/Cargo.toml

This file was deleted.