ethcore-network does not use UtilError
This commit is contained in:
parent
2df61d0a8c
commit
c623e5f232
@ -16,7 +16,6 @@
|
||||
|
||||
use io::IoError;
|
||||
use rlp::*;
|
||||
use util::UtilError;
|
||||
use std::fmt;
|
||||
use ethkey::Error as KeyError;
|
||||
use crypto::Error as CryptoError;
|
||||
@ -96,8 +95,8 @@ pub enum NetworkError {
|
||||
PeerNotFound,
|
||||
/// Peer is diconnected.
|
||||
Disconnect(DisconnectReason),
|
||||
/// Util error.
|
||||
Util(UtilError),
|
||||
/// Invalid NodeId
|
||||
InvalidNodeId,
|
||||
/// Socket IO error.
|
||||
Io(IoError),
|
||||
/// Error concerning the network address parsing subsystem.
|
||||
@ -125,7 +124,7 @@ impl fmt::Display for NetworkError {
|
||||
AddressResolve(Some(ref err)) => format!("{}", err),
|
||||
AddressResolve(_) => "Failed to resolve network address.".into(),
|
||||
StdIo(ref err) => format!("{}", err),
|
||||
Util(ref err) => format!("{}", err),
|
||||
InvalidNodeId => "Invalid node id".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 {
|
||||
fn from(_err: KeyError) -> Self {
|
||||
NetworkError::Auth
|
||||
|
@ -26,7 +26,6 @@ use std::fmt;
|
||||
use std::fs;
|
||||
use std::io::{Read, Write};
|
||||
use util::hash::*;
|
||||
use util::UtilError;
|
||||
use rlp::*;
|
||||
use time::Tm;
|
||||
use error::NetworkError;
|
||||
@ -58,7 +57,7 @@ impl NodeEndpoint {
|
||||
pub fn is_allowed(&self, filter: &IpFilter) -> bool {
|
||||
(self.is_allowed_by_predefined(&filter.predefined) || filter.custom_allow.iter().any(|ipnet| {
|
||||
self.address.ip().is_within(ipnet)
|
||||
}))
|
||||
}))
|
||||
&& !filter.custom_block.iter().any(|ipnet| {
|
||||
self.address.ip().is_within(ipnet)
|
||||
})
|
||||
@ -175,7 +174,7 @@ impl FromStr for Node {
|
||||
type Err = NetworkError;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
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 {
|
||||
(NodeId::new(), NodeEndpoint::from_str(s)?)
|
||||
|
Loading…
Reference in New Issue
Block a user