rpc dependencies relayout
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
use std::sync::Arc;
|
||||
use ethcore::client::Client;
|
||||
use ethcore::service::ClientIoMessage;
|
||||
use ethsync::{EthSync, SyncProvider, ManageNetwork};
|
||||
use ethsync::{SyncProvider, ManageNetwork};
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::{TimerToken, IoHandler, IoContext};
|
||||
|
||||
@@ -27,7 +27,8 @@ const INFO_TIMER: TimerToken = 0;
|
||||
|
||||
pub struct ClientIoHandler {
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<EthSync>,
|
||||
pub sync: Arc<SyncProvider>,
|
||||
pub net: Arc<ManageNetwork>,
|
||||
pub accounts: Arc<AccountProvider>,
|
||||
pub info: Informant,
|
||||
}
|
||||
@@ -40,7 +41,7 @@ impl IoHandler<ClientIoMessage> for ClientIoHandler {
|
||||
fn timeout(&self, _io: &IoContext<ClientIoMessage>, timer: TimerToken) {
|
||||
if let INFO_TIMER = timer {
|
||||
let sync_status = self.sync.status();
|
||||
let network_config = self.sync.network_config();
|
||||
let network_config = self.net.network_config();
|
||||
self.info.tick(&self.client, Some((sync_status, network_config)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,12 +85,11 @@ use rustc_serialize::hex::FromHex;
|
||||
use ctrlc::CtrlC;
|
||||
use util::{H256, ToPretty, PayloadInfo, Bytes, Colour, Applyable, version, journaldb};
|
||||
use util::panics::{MayPanic, ForwardPanic, PanicHandler};
|
||||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path, BlockImportError,
|
||||
ChainNotify, Mode};
|
||||
use ethcore::client::{BlockID, BlockChainClient, ClientConfig, get_db_path, BlockImportError, Mode};
|
||||
use ethcore::error::{ImportError};
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::spec::Spec;
|
||||
use ethsync::{EthSync, NetworkConfiguration};
|
||||
use ethsync::{NetworkConfiguration};
|
||||
use ethcore::miner::{Miner, MinerService, ExternalMiner};
|
||||
use migration::migrate;
|
||||
use informant::Informant;
|
||||
@@ -249,27 +248,32 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
let network_settings = Arc::new(conf.network_settings());
|
||||
|
||||
// Sync
|
||||
let sync = EthSync::new(sync_config, client.clone(), NetworkConfiguration::from(net_settings))
|
||||
.unwrap_or_else(|e| die_with_error("Sync", ethcore::error::Error::Util(e)));
|
||||
service.set_notify(&(sync.clone() as Arc<ChainNotify>));
|
||||
let (sync_provider, manage_network, chain_notify) =
|
||||
modules::sync(sync_config, NetworkConfiguration::from(net_settings), client.clone())
|
||||
.unwrap_or_else(|e| die_with_error("Sync", e));
|
||||
//
|
||||
// let sync = EthSync::new(sync_config, client.clone(), NetworkConfiguration::from(net_settings))
|
||||
// .unwrap_or_else(|e| die_with_error("Sync", ethcore::error::Error::Util(e)));
|
||||
service.set_notify(&chain_notify);
|
||||
|
||||
// if network is active by default
|
||||
if match conf.mode() { Mode::Dark(..) => false, _ => !conf.args.flag_no_network } {
|
||||
sync.start();
|
||||
chain_notify.start();
|
||||
}
|
||||
|
||||
let deps_for_rpc_apis = Arc::new(rpc_apis::Dependencies {
|
||||
signer_port: conf.signer_port(),
|
||||
signer_queue: Arc::new(rpc_apis::ConfirmationsQueue::default()),
|
||||
client: client.clone(),
|
||||
sync: sync.clone(),
|
||||
sync: sync_provider.clone(),
|
||||
net: manage_network.clone(),
|
||||
secret_store: account_service.clone(),
|
||||
miner: miner.clone(),
|
||||
external_miner: external_miner.clone(),
|
||||
logger: logger.clone(),
|
||||
settings: network_settings.clone(),
|
||||
allow_pending_receipt_query: !conf.args.flag_geth,
|
||||
net_service: sync.clone(),
|
||||
net_service: manage_network.clone(),
|
||||
});
|
||||
|
||||
let dependencies = rpc::Dependencies {
|
||||
@@ -317,7 +321,8 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
let io_handler = Arc::new(ClientIoHandler {
|
||||
client: service.client(),
|
||||
info: Informant::new(conf.have_color()),
|
||||
sync: sync.clone(),
|
||||
sync: sync_provider.clone(),
|
||||
net: manage_network.clone(),
|
||||
accounts: account_service.clone(),
|
||||
});
|
||||
service.register_io_handler(io_handler).expect("Error registering IO handler");
|
||||
|
||||
@@ -20,17 +20,16 @@ use ethcore::client::{ChainNotify, BlockChainClient};
|
||||
use ethcore;
|
||||
|
||||
#[cfg(feature="ipc")]
|
||||
fn sync(
|
||||
pub fn sync(
|
||||
sync_cfg: SyncConfig,
|
||||
net_cfg: NetworkConfiguration,
|
||||
client: Arc<BlockChainClient>)
|
||||
-> Result<(Arc<SyncProvider>, Arc<ManageNetwork>, Arc<ChainNotify>), ethcore::error::Error>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#[cfg(not(feature="ipc"))]
|
||||
fn sync(
|
||||
pub fn sync(
|
||||
sync_cfg: SyncConfig,
|
||||
net_cfg: NetworkConfiguration,
|
||||
client: Arc<BlockChainClient>)
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ethsync::{EthSync, ManageNetwork};
|
||||
use ethsync::{ManageNetwork, SyncProvider};
|
||||
use ethcore::miner::{Miner, ExternalMiner};
|
||||
use ethcore::client::Client;
|
||||
use util::RotatingLogger;
|
||||
@@ -76,7 +76,8 @@ pub struct Dependencies {
|
||||
pub signer_port: Option<u16>,
|
||||
pub signer_queue: Arc<ConfirmationsQueue>,
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<EthSync>,
|
||||
pub sync: Arc<SyncProvider>,
|
||||
pub net: Arc<ManageNetwork>,
|
||||
pub secret_store: Arc<AccountProvider>,
|
||||
pub miner: Arc<Miner>,
|
||||
pub external_miner: Arc<ExternalMiner>,
|
||||
|
||||
@@ -28,11 +28,11 @@ extern crate ethcore;
|
||||
extern crate ethcore_util as util;
|
||||
|
||||
use std::sync::Arc;
|
||||
use hypervisor::{HypervisorServiceClient, CLIENT_MODULE_ID, SYNC_MODULE_ID, HYPERVISOR_IPC_URL};
|
||||
use hypervisor::{HypervisorServiceClient, SYNC_MODULE_ID, HYPERVISOR_IPC_URL};
|
||||
use ctrlc::CtrlC;
|
||||
use std::sync::atomic::*;
|
||||
use docopt::Docopt;
|
||||
use ethcore::client::{BlockChainClient, RemoteClient};
|
||||
use ethcore::client::{RemoteClient, ChainNotify};
|
||||
use nanoipc::*;
|
||||
use ethsync::{SyncProvider, SyncConfig, EthSync, ManageNetwork, NetworkConfiguration};
|
||||
use std::thread;
|
||||
@@ -74,7 +74,7 @@ impl Args {
|
||||
let mut sync_config = SyncConfig::default();
|
||||
sync_config.network_id = U256::from_str(&self.arg_network_id).unwrap();
|
||||
|
||||
let mut network_config = NetworkConfiguration {
|
||||
let network_config = NetworkConfiguration {
|
||||
udp_port: self.flag_udp_port,
|
||||
nat_enabled: self.arg_nat_enabled,
|
||||
boot_nodes: self.flag_boot_nodes,
|
||||
@@ -106,8 +106,6 @@ fn run_service<T: ?Sized + Send + Sync + 'static>(addr: &str, stop_guard: Arc<At
|
||||
}
|
||||
|
||||
fn main() {
|
||||
use std::ops::Deref;
|
||||
|
||||
let args: Args = Docopt::new(USAGE)
|
||||
.and_then(|d| d.decode())
|
||||
.unwrap_or_else(|e| e.exit());
|
||||
@@ -121,6 +119,7 @@ fn main() {
|
||||
|
||||
run_service("ipc:///tmp/parity-sync.ipc", stop.clone(), &(sync.clone() as Arc<SyncProvider>));
|
||||
run_service("ipc:///tmp/parity-manage-net.ipc", stop.clone(), &(sync.clone() as Arc<ManageNetwork>));
|
||||
run_service("ipc:///tmp/parity-sync-notify.ipc", stop.clone(), &(sync.clone() as Arc<ChainNotify>));
|
||||
|
||||
let hypervisor_client = nanoipc::init_client::<HypervisorServiceClient<_>>(HYPERVISOR_IPC_URL).unwrap();
|
||||
hypervisor_client.handshake().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user