Merge pull request #7040 from paritytech/squashed_network_error_chain

squashed ethcore-network changes which introduce error-chain
This commit is contained in:
Marek Kotewicz
2017-11-15 18:18:25 +01:00
committed by GitHub
28 changed files with 235 additions and 244 deletions

View File

@@ -28,7 +28,7 @@ use bigint::hash::H256;
use util::{version_data, Address};
use bytes::Bytes;
use ansi_term::Colour;
use ethsync::{NetworkConfiguration, validate_node_url, NetworkError};
use ethsync::{NetworkConfiguration, validate_node_url, self};
use ethcore::ethstore::ethkey::{Secret, Public};
use ethcore::client::{VMType};
use ethcore::miner::{MinerOptions, Banning, StratumOptions};
@@ -700,9 +700,9 @@ impl Configuration {
let lines = buffer.lines().map(|s| s.trim().to_owned()).filter(|s| !s.is_empty() && !s.starts_with("#")).collect::<Vec<_>>();
for line in &lines {
match validate_node_url(line) {
match validate_node_url(line).map(Into::into) {
None => continue,
Some(NetworkError::AddressResolve(_)) => return Err(format!("Failed to resolve hostname of a boot node: {}", line)),
Some(ethsync::ErrorKind::AddressResolve(_)) => return Err(format!("Failed to resolve hostname of a boot node: {}", line)),
Some(_) => return Err(format!("Invalid node address format given for a boot node: {}", line)),
}
}

View File

@@ -29,7 +29,7 @@ use cache::CacheConfig;
use dir::DatabaseDirectories;
use upgrade::{upgrade, upgrade_data_paths};
use migration::migrate;
use ethsync::{validate_node_url, NetworkError};
use ethsync::{validate_node_url, self};
use path;
pub fn to_duration(s: &str) -> Result<Duration, String> {
@@ -181,9 +181,9 @@ pub fn parity_ipc_path(base: &str, path: &str, shift: u16) -> String {
pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
match *bootnodes {
Some(ref x) if !x.is_empty() => x.split(',').map(|s| {
match validate_node_url(s) {
match validate_node_url(s).map(Into::into) {
None => Ok(s.to_owned()),
Some(NetworkError::AddressResolve(_)) => Err(format!("Failed to resolve hostname of a boot node: {}", s)),
Some(ethsync::ErrorKind::AddressResolve(_)) => Err(format!("Failed to resolve hostname of a boot node: {}", s)),
Some(_) => Err(format!("Invalid node address format given for a boot node: {}", s)),
}
}).collect(),

View File

@@ -17,7 +17,7 @@
use std::sync::Arc;
use ethcore::client::BlockChainClient;
use ethsync::{AttachedProtocol, SyncConfig, NetworkConfiguration, NetworkError, Params, ConnectionFilter};
use ethsync::{self, AttachedProtocol, SyncConfig, NetworkConfiguration, Params, ConnectionFilter};
use ethcore::snapshot::SnapshotService;
use light::Provider;
@@ -36,7 +36,7 @@ pub fn sync(
_log_settings: &LogConfig,
attached_protos: Vec<AttachedProtocol>,
connection_filter: Option<Arc<ConnectionFilter>>,
) -> Result<SyncModules, NetworkError> {
) -> Result<SyncModules, ethsync::Error> {
let eth_sync = EthSync::new(Params {
config: sync_cfg,
chain: client,