Die error_chain, die (#10747)

* Replace error chain for network error

* Fix usages and add manual From impls

* OnDemand Error and remove remaining dependencies

* Die error_chain, die.

* DIE

* Hasta la vista, baby
This commit is contained in:
Andrew Jones
2019-06-17 07:44:59 +01:00
committed by David
parent dbdb57a8c0
commit bf55db4c7e
29 changed files with 214 additions and 225 deletions

View File

@@ -22,7 +22,7 @@ use std::time::Duration;
use bytes::Bytes;
use devp2p::NetworkService;
use network::{NetworkProtocolHandler, NetworkContext, PeerId, ProtocolId,
NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error, ErrorKind,
NetworkConfiguration as BasicNetworkConfiguration, NonReservedPeerMode, Error,
ConnectionFilter};
use network::client_version::ClientVersion;
@@ -593,7 +593,7 @@ impl ChainNotify for EthSync {
match self.network.start() {
Err((err, listen_address)) => {
match err.into() {
ErrorKind::Io(ref e) if e.kind() == io::ErrorKind::AddrInUse => {
Error::Io(ref e) if e.kind() == io::ErrorKind::AddrInUse => {
warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", listen_address.expect("Listen address is not set."))
},
err => warn!("Error starting network: {}", err),
@@ -983,7 +983,7 @@ impl ManageNetwork for LightSync {
match self.network.start() {
Err((err, listen_address)) => {
match err.into() {
ErrorKind::Io(ref e) if e.kind() == io::ErrorKind::AddrInUse => {
Error::Io(ref e) if e.kind() == io::ErrorKind::AddrInUse => {
warn!("Network port {:?} is already in use, make sure that another instance of an Ethereum client is not running or change the port using the --port option.", listen_address.expect("Listen address is not set."))
},
err => warn!("Error starting network: {}", err),

View File

@@ -435,13 +435,13 @@ impl BlockCollection {
},
None => {
warn!("Got body with no header {}", h);
Err(network::ErrorKind::BadProtocol.into())
Err(network::Error::BadProtocol)
}
}
}
None => {
trace!(target: "sync", "Ignored unknown/stale block body. tx_root = {:?}, uncles = {:?}", header_id.transactions_root, header_id.uncles);
Err(network::ErrorKind::BadProtocol.into())
Err(network::Error::BadProtocol)
}
}
}
@@ -463,7 +463,7 @@ impl BlockCollection {
},
None => {
warn!("Got receipt with no header {}", h);
return Err(network::ErrorKind::BadProtocol.into())
return Err(network::Error::BadProtocol)
}
}
}
@@ -471,7 +471,7 @@ impl BlockCollection {
},
hash_map::Entry::Vacant(_) => {
trace!(target: "sync", "Ignored unknown/stale block receipt {:?}", receipt_root);
Err(network::ErrorKind::BadProtocol.into())
Err(network::Error::BadProtocol)
}
}
}

View File

@@ -76,5 +76,5 @@ mod api;
pub use api::*;
pub use chain::{SyncStatus, SyncState};
pub use devp2p::validate_node_url;
pub use network::{NonReservedPeerMode, Error, ErrorKind, ConnectionFilter, ConnectionDirection};
pub use network::{NonReservedPeerMode, Error, ConnectionFilter, ConnectionDirection};
pub use private_tx::{PrivateTxHandler, NoopPrivateTxHandler, SimplePrivateTxHandler};