@@ -53,6 +53,7 @@ Account Options:
|
||||
--no-import-keys Do not import keys from legacy clients.
|
||||
|
||||
Networking Options:
|
||||
--no-network Disable p2p networking.
|
||||
--port PORT Override the port on which the node should listen
|
||||
[default: 30303].
|
||||
--peers NUM Try to maintain that many peers [default: 25].
|
||||
@@ -268,6 +269,7 @@ pub struct Args {
|
||||
pub flag_format: Option<String>,
|
||||
pub flag_jitvm: bool,
|
||||
pub flag_no_color: bool,
|
||||
pub flag_no_network: bool,
|
||||
// legacy...
|
||||
pub flag_geth: bool,
|
||||
pub flag_nodekey: Option<String>,
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use ethcore::client::Client;
|
||||
use ethcore::service::NetSyncMessage;
|
||||
use ethcore::service::{NetSyncMessage, SyncMessage};
|
||||
use ethsync::EthSync;
|
||||
use util::keys::store::AccountService;
|
||||
use util::{TimerToken, IoHandler, IoContext};
|
||||
use util::{TimerToken, IoHandler, IoContext, NetworkService, NetworkIoMessage};
|
||||
|
||||
use informant::Informant;
|
||||
|
||||
@@ -33,6 +33,7 @@ pub struct ClientIoHandler {
|
||||
pub sync: Arc<EthSync>,
|
||||
pub accounts: Arc<AccountService>,
|
||||
pub info: Informant,
|
||||
pub network: Arc<NetworkService<SyncMessage>>,
|
||||
}
|
||||
|
||||
impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||
@@ -48,6 +49,21 @@ impl IoHandler<NetSyncMessage> for ClientIoHandler {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn message(&self, _io: &IoContext<NetSyncMessage>, message: &NetSyncMessage) {
|
||||
match *message {
|
||||
NetworkIoMessage::User(SyncMessage::StartNetwork) => {
|
||||
info!("Starting network");
|
||||
self.network.start().unwrap_or_else(|e| warn!("Error starting network: {:?}", e));
|
||||
EthSync::register(&*self.network, self.sync.clone()).unwrap_or_else(|e| warn!("Error registering eth protocol handler: {}", e));
|
||||
},
|
||||
NetworkIoMessage::User(SyncMessage::StopNetwork) => {
|
||||
info!("Stopping network");
|
||||
self.network.stop().unwrap_or_else(|e| warn!("Error stopping network: {:?}", e));
|
||||
},
|
||||
_ => {/* Ignore other messages */},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ use std::thread::sleep;
|
||||
use std::time::Duration;
|
||||
use rustc_serialize::hex::FromHex;
|
||||
use ctrlc::CtrlC;
|
||||
use util::{H256, ToPretty, NetworkConfiguration, PayloadInfo, Bytes};
|
||||
use util::{H256, ToPretty, NetworkConfiguration, PayloadInfo, Bytes, UtilError};
|
||||
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
||||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path};
|
||||
use ethcore::error::{Error, ImportError};
|
||||
@@ -199,7 +199,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
|
||||
// Build client
|
||||
let mut service = ClientService::start(
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), miner.clone()
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), miner.clone(), !conf.args.flag_no_network
|
||||
).unwrap_or_else(|e| die_with_error("Client", e));
|
||||
|
||||
panic_handler.forward_from(&service);
|
||||
@@ -209,7 +209,8 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
let network_settings = Arc::new(conf.network_settings());
|
||||
|
||||
// Sync
|
||||
let sync = EthSync::register(service.network(), sync_config, client.clone());
|
||||
let sync = EthSync::new(sync_config, client.clone());
|
||||
EthSync::register(&*service.network(), sync.clone()).unwrap_or_else(|e| die_with_error("Error registering eth protocol handler", UtilError::from(e).into()));
|
||||
|
||||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
||||
signer_port: conf.signer_port(),
|
||||
@@ -270,8 +271,9 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
info: Informant::new(conf.have_color()),
|
||||
sync: sync.clone(),
|
||||
accounts: account_service.clone(),
|
||||
network: service.network(),
|
||||
});
|
||||
service.io().register_handler(io_handler).expect("Error registering IO handler");
|
||||
service.register_io_handler(io_handler).expect("Error registering IO handler");
|
||||
|
||||
if conf.args.cmd_ui {
|
||||
url::open("http://localhost:8080/")
|
||||
@@ -314,7 +316,7 @@ fn execute_export(conf: Configuration) {
|
||||
|
||||
// Build client
|
||||
let service = ClientService::start(
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), Arc::new(Miner::default()),
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), Arc::new(Miner::default()), false
|
||||
).unwrap_or_else(|e| die_with_error("Client", e));
|
||||
|
||||
panic_handler.forward_from(&service);
|
||||
@@ -385,7 +387,7 @@ fn execute_import(conf: Configuration) {
|
||||
|
||||
// Build client
|
||||
let service = ClientService::start(
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), Arc::new(Miner::default()),
|
||||
client_config, spec, net_settings, Path::new(&conf.path()), Arc::new(Miner::default()), false
|
||||
).unwrap_or_else(|e| die_with_error("Client", e));
|
||||
|
||||
panic_handler.forward_from(&service);
|
||||
|
||||
Reference in New Issue
Block a user