Removed ethcore-util dependency from ethcore-network (#7180)

* Removed ethcore-util dependency

* Removed snappy
This commit is contained in:
Arkadiy Paronyan
2017-12-02 10:08:04 +01:00
committed by GitHub
parent c544c3e518
commit dde6baedec
14 changed files with 36 additions and 197 deletions

View File

@@ -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" }
@@ -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 }

View File

@@ -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::*;
@@ -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 {
@@ -136,6 +137,7 @@ impl NetworkConfiguration {
ip_filter: IpFilter::default(),
reserved_nodes: Vec::new(),
non_reserved_mode: NonReservedPeerMode::Accept,
client_version: "Parity-network".into(),
}
}
@@ -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
@@ -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>>;
@@ -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,
@@ -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())))

View File

@@ -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;

View File

@@ -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,

View File

@@ -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());