diff --git a/util/network-devp2p/src/connection.rs b/util/network-devp2p/src/connection.rs
index e32439756fd..ea3b99d4181 100644
--- a/util/network-devp2p/src/connection.rs
+++ b/util/network-devp2p/src/connection.rs
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use std::sync::Arc;
use std::collections::VecDeque;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering};
@@ -28,7 +27,6 @@ use rlp::*;
use std::io::{self, Cursor, Read, Write};
use io::{IoContext, StreamToken};
use handshake::Handshake;
-use stats::NetworkStats;
use rcrypto::blockmodes::*;
use rcrypto::aessafe::*;
use rcrypto::symmetriccipher::*;
@@ -61,8 +59,6 @@ pub struct GenericConnection {
send_queue: VecDeque>,
/// Event flags this connection expects
interest: Ready,
- /// Shared network statistics
- stats: Arc,
/// Registered flag
registered: AtomicBool,
}
@@ -87,7 +83,6 @@ impl GenericConnection {
match sock_ref.take(max as u64).try_read(unsafe { self.rec_buf.bytes_mut() }) {
Ok(Some(size)) if size != 0 => {
unsafe { self.rec_buf.advance_mut(size); }
- self.stats.inc_recv(size);
trace!(target:"network", "{}: Read {} of {} bytes", self.token, self.rec_buf.len(), self.rec_size);
if self.rec_size != 0 && self.rec_buf.len() == self.rec_size {
self.rec_size = 0;
@@ -141,11 +136,9 @@ impl GenericConnection {
match self.socket.try_write(Buf::bytes(&buf)) {
Ok(Some(size)) if (pos + size) < send_size => {
buf.advance(size);
- self.stats.inc_send(size);
Ok(WriteStatus::Ongoing)
},
Ok(Some(size)) if (pos + size) == send_size => {
- self.stats.inc_send(size);
trace!(target:"network", "{}: Wrote {} bytes", self.token, send_size);
Ok(WriteStatus::Complete)
},
@@ -171,7 +164,7 @@ pub type Connection = GenericConnection;
impl Connection {
/// Create a new connection with given id and socket.
- pub fn new(token: StreamToken, socket: TcpStream, stats: Arc) -> Connection {
+ pub fn new(token: StreamToken, socket: TcpStream) -> Connection {
Connection {
token: token,
socket: socket,
@@ -179,7 +172,6 @@ impl Connection {
rec_buf: Bytes::new(),
rec_size: 0,
interest: Ready::hup() | Ready::readable(),
- stats: stats,
registered: AtomicBool::new(false),
}
}
@@ -213,7 +205,6 @@ impl Connection {
rec_size: 0,
send_queue: self.send_queue.clone(),
interest: Ready::hup(),
- stats: self.stats.clone(),
registered: AtomicBool::new(false),
})
}
@@ -507,13 +498,11 @@ mod tests {
use std::cmp;
use std::collections::VecDeque;
use std::io::{Read, Write, Cursor, ErrorKind, Result, Error};
- use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use mio::{Ready};
use ethcore_bytes::Bytes;
use io::*;
- use super::super::stats::*;
use super::*;
pub struct TestSocket {
@@ -625,7 +614,6 @@ mod tests {
rec_buf: Bytes::new(),
rec_size: 0,
interest: Ready::hup() | Ready::readable(),
- stats: Arc::::new(NetworkStats::new()),
registered: AtomicBool::new(false),
}
}
@@ -648,7 +636,6 @@ mod tests {
rec_buf: Bytes::new(),
rec_size: 0,
interest: Ready::hup() | Ready::readable(),
- stats: Arc::::new(NetworkStats::new()),
registered: AtomicBool::new(false),
}
}
diff --git a/util/network-devp2p/src/handshake.rs b/util/network-devp2p/src/handshake.rs
index 240046a98e1..dbd31c5a87f 100644
--- a/util/network-devp2p/src/handshake.rs
+++ b/util/network-devp2p/src/handshake.rs
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see .
-use std::sync::Arc;
use rand::random;
use hash::write_keccak;
use mio::tcp::*;
@@ -23,7 +22,6 @@ use ethcore_bytes::Bytes;
use rlp::*;
use connection::{Connection};
use node_table::NodeId;
-use stats::NetworkStats;
use io::{IoContext, StreamToken};
use ethkey::{KeyPair, Public, Secret, recover, sign, Generator, Random};
use crypto::{ecdh, ecies};
@@ -82,10 +80,10 @@ const ECIES_OVERHEAD: usize = 113;
impl Handshake {
/// Create a new handshake object
- pub fn new(token: StreamToken, id: Option<&NodeId>, socket: TcpStream, nonce: &H256, stats: Arc) -> Result {
+ pub fn new(token: StreamToken, id: Option<&NodeId>, socket: TcpStream, nonce: &H256) -> Result {
Ok(Handshake {
id: if let Some(id) = id { id.clone()} else { NodeId::new() },
- connection: Connection::new(token, socket, stats),
+ connection: Connection::new(token, socket),
originated: false,
state: HandshakeState::New,
ecdhe: Random.generate()?,
@@ -329,13 +327,11 @@ impl Handshake {
#[cfg(test)]
mod test {
- use std::sync::Arc;
use rustc_hex::FromHex;
use super::*;
use ethereum_types::H256;
use io::*;
use mio::tcp::TcpStream;
- use stats::NetworkStats;
use ethkey::Public;
fn check_auth(h: &Handshake, version: u64) {
@@ -355,7 +351,7 @@ mod test {
let addr = "127.0.0.1:50556".parse().unwrap();
let socket = TcpStream::connect(&addr).unwrap();
let nonce = H256::new();
- Handshake::new(0, to, socket, &nonce, Arc::new(NetworkStats::new())).unwrap()
+ Handshake::new(0, to, socket, &nonce).unwrap()
}
fn test_io() -> IoContext {
diff --git a/util/network-devp2p/src/host.rs b/util/network-devp2p/src/host.rs
index c23527c328e..87e9a02789e 100644
--- a/util/network-devp2p/src/host.rs
+++ b/util/network-devp2p/src/host.rs
@@ -39,7 +39,6 @@ use network::{NetworkConfiguration, NetworkIoMessage, ProtocolId, PeerId, Packet
use network::{NonReservedPeerMode, NetworkContext as NetworkContextTrait};
use network::HostInfo as HostInfoTrait;
use network::{SessionInfo, Error, ErrorKind, DisconnectReason, NetworkProtocolHandler};
-use stats::NetworkStats;
use discovery::{Discovery, TableUpdates, NodeEntry};
use ip_utils::{map_external_address, select_public_address};
use path::restrict_permissions_owner;
@@ -245,7 +244,6 @@ pub struct Host {
handlers: RwLock>>,
timers: RwLock>,
timer_counter: RwLock,
- stats: Arc,
reserved_nodes: RwLock>,
stopping: AtomicBool,
filter: Option>,
@@ -253,7 +251,7 @@ pub struct Host {
impl Host {
/// Create a new instance
- pub fn new(mut config: NetworkConfiguration, stats: Arc, filter: Option>) -> Result {
+ pub fn new(mut config: NetworkConfiguration, filter: Option>) -> Result {
let mut listen_address = match config.listen_address {
None => SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), DEFAULT_PORT)),
Some(addr) => addr,
@@ -301,7 +299,6 @@ impl Host {
handlers: RwLock::new(HashMap::new()),
timers: RwLock::new(HashMap::new()),
timer_counter: RwLock::new(USER_TIMER),
- stats: stats,
reserved_nodes: RwLock::new(HashSet::new()),
stopping: AtomicBool::new(false),
filter: filter,
@@ -616,7 +613,7 @@ impl Host {
let mut sessions = self.sessions.write();
let token = sessions.insert_with_opt(|token| {
- match Session::new(io, socket, token, id, &nonce, self.stats.clone(), &self.info.read()) {
+ match Session::new(io, socket, token, id, &nonce, &self.info.read()) {
Ok(s) => Some(Arc::new(Mutex::new(s))),
Err(e) => {
debug!(target: "network", "Session create error: {:?}", e);
@@ -793,7 +790,6 @@ impl Host {
return;
}
for p in ready_data {
- self.stats.inc_sessions();
let reserved = self.reserved_nodes.read();
if let Some(h) = handlers.get(&p).clone() {
h.connected(&NetworkContext::new(io, p, Some(session.clone()), self.sessions.clone(), &reserved), &token);
@@ -1150,6 +1146,6 @@ fn host_client_url() {
let mut config = NetworkConfiguration::new_local();
let key = "6f7b0d801bc7b5ce7bbd930b84fd0369b3eb25d09be58d64ba811091046f3aa2".parse().unwrap();
config.use_secret = Some(key);
- let host: Host = Host::new(config, Arc::new(NetworkStats::new()), None).unwrap();
+ let host: Host = Host::new(config, None).unwrap();
assert!(host.local_url().starts_with("enode://101b3ef5a4ea7a1c7928e24c4c75fd053c235d7b80c22ae5c03d145d0ac7396e2a4ffff9adee3133a7b05044a5cee08115fd65145e5165d646bde371010d803c@"));
}
diff --git a/util/network-devp2p/src/lib.rs b/util/network-devp2p/src/lib.rs
index 0dfda0b16e4..fc3e66e3a5d 100644
--- a/util/network-devp2p/src/lib.rs
+++ b/util/network-devp2p/src/lib.rs
@@ -102,12 +102,10 @@ mod session;
mod discovery;
mod service;
mod node_table;
-mod stats;
mod ip_utils;
mod connection_filter;
pub use service::NetworkService;
-pub use stats::NetworkStats;
pub use connection_filter::{ConnectionFilter, ConnectionDirection};
pub use host::NetworkContext;
diff --git a/util/network-devp2p/src/service.rs b/util/network-devp2p/src/service.rs
index 95867f8eb0a..711ee95cf3b 100644
--- a/util/network-devp2p/src/service.rs
+++ b/util/network-devp2p/src/service.rs
@@ -17,7 +17,6 @@
use network::{Error, NetworkConfiguration, NetworkProtocolHandler, NonReservedPeerMode};
use network::{NetworkContext, PeerId, ProtocolId, NetworkIoMessage};
use host::Host;
-use stats::NetworkStats;
use io::*;
use parking_lot::RwLock;
use std::sync::Arc;
@@ -46,7 +45,6 @@ pub struct NetworkService {
io_service: IoService,
host_info: String,
host: RwLock