Split IO and network crates (#1828)
* Abort on panic * Split IO and network crates * Restore panic handler * Fixed doc tests
This commit is contained in:
committed by
Marek Kotewicz
parent
08f30fc1a8
commit
05bfdc508e
@@ -23,7 +23,7 @@ use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use ethcore_logger::{setup_log, Config as LogConfig};
|
||||
use util::panics::{PanicHandler, ForwardPanic};
|
||||
use io::{PanicHandler, ForwardPanic};
|
||||
use util::{PayloadInfo, ToPretty};
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::client::{Mode, DatabaseCompactionProfile, Switch, VMType, BlockImportError, BlockChainClient, BlockID};
|
||||
|
||||
@@ -21,13 +21,14 @@ use std::path::PathBuf;
|
||||
use std::cmp::max;
|
||||
use cli::{USAGE, Args};
|
||||
use docopt::{Docopt, Error as DocoptError};
|
||||
use util::{Hashable, NetworkConfiguration, U256, Uint, is_valid_node_url, Bytes, version_data, Secret, Address};
|
||||
use util::network_settings::NetworkSettings;
|
||||
use util::{Hashable, U256, Uint, Bytes, version_data, Secret, Address};
|
||||
use util::log::Colour;
|
||||
use ethsync::{NetworkConfiguration, is_valid_node_url};
|
||||
use ethcore::client::{VMType, Mode};
|
||||
use ethcore::miner::MinerOptions;
|
||||
|
||||
use rpc::{IpcConfiguration, HttpConfiguration};
|
||||
use ethcore_rpc::NetworkSettings;
|
||||
use cache::CacheConfig;
|
||||
use helpers::{to_duration, to_mode, to_block_id, to_u256, to_pending_set, to_price, replace_home,
|
||||
geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address};
|
||||
@@ -397,8 +398,8 @@ impl Configuration {
|
||||
ret.nat_enabled = self.args.flag_nat == "any" || self.args.flag_nat == "upnp";
|
||||
ret.boot_nodes = try!(to_bootnodes(&self.args.flag_bootnodes));
|
||||
let (listen, public) = try!(self.net_addresses());
|
||||
ret.listen_address = listen;
|
||||
ret.public_address = public;
|
||||
ret.listen_address = listen.map(|l| format!("{}", l));
|
||||
ret.public_address = public.map(|p| format!("{}", p));
|
||||
ret.use_secret = self.args.flag_node_key.as_ref().map(|s| s.parse::<Secret>().unwrap_or_else(|_| s.sha3()));
|
||||
ret.discovery_enabled = !self.args.flag_no_discovery && !self.args.flag_nodiscover;
|
||||
ret.max_peers = self.max_peers();
|
||||
@@ -408,9 +409,7 @@ impl Configuration {
|
||||
ret.config_path = Some(net_path.to_str().unwrap().to_owned());
|
||||
ret.reserved_nodes = try!(self.init_reserved_nodes());
|
||||
|
||||
if self.args.flag_reserved_only {
|
||||
ret.non_reserved_mode = ::util::network::NonReservedPeerMode::Deny;
|
||||
}
|
||||
ret.allow_non_reserved = !self.args.flag_reserved_only;
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
@@ -552,7 +551,7 @@ mod tests {
|
||||
use super::*;
|
||||
use cli::USAGE;
|
||||
use docopt::Docopt;
|
||||
use util::network_settings::NetworkSettings;
|
||||
use ethcore_rpc::NetworkSettings;
|
||||
use ethcore::client::{VMType, BlockID};
|
||||
use helpers::{replace_home, default_network_config};
|
||||
use run::RunCmd;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::net::SocketAddr;
|
||||
use util::panics::PanicHandler;
|
||||
use io::PanicHandler;
|
||||
use rpc_apis;
|
||||
use helpers::replace_home;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::io::{Write, Read, BufReader, BufRead};
|
||||
use std::time::Duration;
|
||||
use std::path::Path;
|
||||
use std::fs::File;
|
||||
use util::{clean_0x, U256, Uint, Address, path, is_valid_node_url, H256, CompactionProfile};
|
||||
use util::{clean_0x, U256, Uint, Address, path, H256, CompactionProfile};
|
||||
use util::journaldb::Algorithm;
|
||||
use ethcore::client::{Mode, BlockID, Switch, VMType, DatabaseCompactionProfile, ClientConfig};
|
||||
use ethcore::miner::PendingSet;
|
||||
@@ -28,6 +28,7 @@ use dir::Directories;
|
||||
use params::Pruning;
|
||||
use upgrade::upgrade;
|
||||
use migration::migrate;
|
||||
use ethsync::is_valid_node_url;
|
||||
|
||||
pub fn to_duration(s: &str) -> Result<Duration, String> {
|
||||
to_seconds(s).map(Duration::from_secs)
|
||||
@@ -167,11 +168,11 @@ pub fn to_bootnodes(bootnodes: &Option<String>) -> Result<Vec<String>, String> {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn default_network_config() -> ::util::NetworkConfiguration {
|
||||
use util::{NetworkConfiguration, NonReservedPeerMode};
|
||||
pub fn default_network_config() -> ::ethsync::NetworkConfiguration {
|
||||
use ethsync::NetworkConfiguration;
|
||||
NetworkConfiguration {
|
||||
config_path: Some(replace_home("$HOME/.parity/network")),
|
||||
listen_address: Some("0.0.0.0:30303".parse().unwrap()),
|
||||
listen_address: Some("0.0.0.0:30303".into()),
|
||||
public_address: None,
|
||||
udp_port: None,
|
||||
nat_enabled: true,
|
||||
@@ -181,7 +182,7 @@ pub fn default_network_config() -> ::util::NetworkConfiguration {
|
||||
max_peers: 50,
|
||||
min_peers: 25,
|
||||
reserved_nodes: Vec::new(),
|
||||
non_reserved_mode: NonReservedPeerMode::Accept,
|
||||
allow_non_reserved: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use ethcore::client::Client;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethsync::{SyncProvider, ManageNetwork};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::{TimerToken, IoHandler, IoContext};
|
||||
use io::{TimerToken, IoHandler, IoContext};
|
||||
|
||||
use informant::Informant;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ extern crate time;
|
||||
extern crate number_prefix;
|
||||
extern crate rpassword;
|
||||
extern crate semver;
|
||||
extern crate ethcore_io as io;
|
||||
extern crate ethcore_ipc as ipc;
|
||||
extern crate ethcore_ipc_nano as nanoipc;
|
||||
#[macro_use]
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use ethcore::client::BlockChainClient;
|
||||
use ethcore;
|
||||
use hypervisor::Hypervisor;
|
||||
use ethsync::{SyncConfig, NetworkConfiguration};
|
||||
use ethsync::{SyncConfig, NetworkConfiguration, NetworkError};
|
||||
#[cfg(not(feature="ipc"))]
|
||||
use self::no_ipc_deps::*;
|
||||
#[cfg(feature="ipc")]
|
||||
@@ -103,7 +102,7 @@ pub fn sync
|
||||
_client: Arc<BlockChainClient>,
|
||||
log_settings: &LogConfig,
|
||||
)
|
||||
-> Result<SyncModules, ethcore::error::Error>
|
||||
-> Result<SyncModules, NetworkError>
|
||||
{
|
||||
let mut hypervisor = hypervisor_ref.take().expect("There should be hypervisor for ipc configuration");
|
||||
hypervisor = hypervisor.module(SYNC_MODULE_ID, "parity", sync_arguments(sync_cfg, net_cfg, log_settings));
|
||||
@@ -128,8 +127,8 @@ pub fn sync
|
||||
client: Arc<BlockChainClient>,
|
||||
_log_settings: &LogConfig,
|
||||
)
|
||||
-> Result<SyncModules, ethcore::error::Error>
|
||||
-> Result<SyncModules, NetworkError>
|
||||
{
|
||||
let eth_sync = try!(EthSync::new(sync_cfg, client, net_cfg).map_err(ethcore::error::Error::Util));
|
||||
let eth_sync = try!(EthSync::new(sync_cfg, client, net_cfg));
|
||||
Ok((eth_sync.clone() as Arc<SyncProvider>, eth_sync.clone() as Arc<ManageNetwork>, eth_sync.clone() as Arc<ChainNotify>))
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use std::net::SocketAddr;
|
||||
use util::panics::PanicHandler;
|
||||
use io::PanicHandler;
|
||||
use ethcore_rpc::{RpcServerError, RpcServer as Server};
|
||||
use jsonipc;
|
||||
use rpc_apis;
|
||||
|
||||
@@ -20,12 +20,11 @@ use std::cmp::PartialEq;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use util::RotatingLogger;
|
||||
use util::network_settings::NetworkSettings;
|
||||
use ethcore::miner::{Miner, ExternalMiner};
|
||||
use ethcore::client::Client;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethsync::{ManageNetwork, SyncProvider};
|
||||
use ethcore_rpc::Extendable;
|
||||
use ethcore_rpc::{Extendable, NetworkSettings};
|
||||
pub use ethcore_rpc::ConfirmationsQueue;
|
||||
|
||||
|
||||
|
||||
@@ -20,9 +20,10 @@ use std::io::ErrorKind;
|
||||
use ctrlc::CtrlC;
|
||||
use fdlimit::raise_fd_limit;
|
||||
use ethcore_logger::{Config as LogConfig, setup_log};
|
||||
use util::network_settings::NetworkSettings;
|
||||
use util::{Colour, version, NetworkConfiguration, U256};
|
||||
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
||||
use ethcore_rpc::NetworkSettings;
|
||||
use ethsync::NetworkConfiguration;
|
||||
use util::{Colour, version, U256};
|
||||
use io::{MayPanic, ForwardPanic, PanicHandler};
|
||||
use ethcore::client::{Mode, Switch, DatabaseCompactionProfile, VMType, ChainNotify};
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::io;
|
||||
use std::sync::Arc;
|
||||
use std::path::PathBuf;
|
||||
use ansi_term::Colour;
|
||||
use util::panics::{ForwardPanic, PanicHandler};
|
||||
use io::{ForwardPanic, PanicHandler};
|
||||
use util::path::restrict_permissions_owner;
|
||||
use rpc_apis;
|
||||
use ethcore_signer as signer;
|
||||
|
||||
Reference in New Issue
Block a user