ethcore-network does not use UtilError

This commit is contained in:
debris 2017-09-05 11:14:28 +02:00
parent 2df61d0a8c
commit c623e5f232
2 changed files with 5 additions and 13 deletions

View File

@ -16,7 +16,6 @@
use io::IoError; use io::IoError;
use rlp::*; use rlp::*;
use util::UtilError;
use std::fmt; use std::fmt;
use ethkey::Error as KeyError; use ethkey::Error as KeyError;
use crypto::Error as CryptoError; use crypto::Error as CryptoError;
@ -96,8 +95,8 @@ pub enum NetworkError {
PeerNotFound, PeerNotFound,
/// Peer is diconnected. /// Peer is diconnected.
Disconnect(DisconnectReason), Disconnect(DisconnectReason),
/// Util error. /// Invalid NodeId
Util(UtilError), InvalidNodeId,
/// Socket IO error. /// Socket IO error.
Io(IoError), Io(IoError),
/// Error concerning the network address parsing subsystem. /// Error concerning the network address parsing subsystem.
@ -125,7 +124,7 @@ impl fmt::Display for NetworkError {
AddressResolve(Some(ref err)) => format!("{}", err), AddressResolve(Some(ref err)) => format!("{}", err),
AddressResolve(_) => "Failed to resolve network address.".into(), AddressResolve(_) => "Failed to resolve network address.".into(),
StdIo(ref err) => format!("{}", err), StdIo(ref err) => format!("{}", err),
Util(ref err) => format!("{}", err), InvalidNodeId => "Invalid node id".into(),
OversizedPacket => "Packet is too large".into(), OversizedPacket => "Packet is too large".into(),
}; };
@ -151,12 +150,6 @@ impl From<IoError> for NetworkError {
} }
} }
impl From<UtilError> for NetworkError {
fn from(err: UtilError) -> NetworkError {
NetworkError::Util(err)
}
}
impl From<KeyError> for NetworkError { impl From<KeyError> for NetworkError {
fn from(_err: KeyError) -> Self { fn from(_err: KeyError) -> Self {
NetworkError::Auth NetworkError::Auth

View File

@ -26,7 +26,6 @@ use std::fmt;
use std::fs; use std::fs;
use std::io::{Read, Write}; use std::io::{Read, Write};
use util::hash::*; use util::hash::*;
use util::UtilError;
use rlp::*; use rlp::*;
use time::Tm; use time::Tm;
use error::NetworkError; use error::NetworkError;
@ -58,7 +57,7 @@ impl NodeEndpoint {
pub fn is_allowed(&self, filter: &IpFilter) -> bool { pub fn is_allowed(&self, filter: &IpFilter) -> bool {
(self.is_allowed_by_predefined(&filter.predefined) || filter.custom_allow.iter().any(|ipnet| { (self.is_allowed_by_predefined(&filter.predefined) || filter.custom_allow.iter().any(|ipnet| {
self.address.ip().is_within(ipnet) self.address.ip().is_within(ipnet)
})) }))
&& !filter.custom_block.iter().any(|ipnet| { && !filter.custom_block.iter().any(|ipnet| {
self.address.ip().is_within(ipnet) self.address.ip().is_within(ipnet)
}) })
@ -175,7 +174,7 @@ impl FromStr for Node {
type Err = NetworkError; type Err = NetworkError;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let (id, endpoint) = if s.len() > 136 && &s[0..8] == "enode://" && &s[136..137] == "@" { let (id, endpoint) = if s.len() > 136 && &s[0..8] == "enode://" && &s[136..137] == "@" {
(s[8..136].parse().map_err(UtilError::from)?, NodeEndpoint::from_str(&s[137..])?) (s[8..136].parse().map_err(|_| NetworkError::InvalidNodeId)?, NodeEndpoint::from_str(&s[137..])?)
} }
else { else {
(NodeId::new(), NodeEndpoint::from_str(s)?) (NodeId::new(), NodeEndpoint::from_str(s)?)