Merge branch 'master' of github.com:ethcore/parity into spec_load_errors
This commit is contained in:
@@ -243,6 +243,8 @@ Snapshot Options:
|
||||
index, hash, or 'latest'. Note that taking snapshots at
|
||||
non-recent blocks will only work with --pruning archive
|
||||
[default: latest]
|
||||
--no-periodic-snapshot Disable automated snapshots which usually occur once
|
||||
every 10000 blocks.
|
||||
|
||||
Virtual Machine Options:
|
||||
--jitvm Enable the JIT VM.
|
||||
@@ -382,6 +384,7 @@ pub struct Args {
|
||||
pub flag_from: String,
|
||||
pub flag_to: String,
|
||||
pub flag_at: String,
|
||||
pub flag_no_periodic_snapshot: bool,
|
||||
pub flag_format: Option<String>,
|
||||
pub flag_jitvm: bool,
|
||||
pub flag_log_file: Option<String>,
|
||||
|
||||
@@ -226,6 +226,7 @@ impl Configuration {
|
||||
ui: self.args.cmd_ui,
|
||||
name: self.args.flag_identity,
|
||||
custom_bootnodes: self.args.flag_bootnodes.is_some(),
|
||||
no_periodic_snapshot: self.args.flag_no_periodic_snapshot,
|
||||
};
|
||||
Cmd::Run(run_cmd)
|
||||
};
|
||||
@@ -802,6 +803,7 @@ mod tests {
|
||||
ui: false,
|
||||
name: "".into(),
|
||||
custom_bootnodes: false,
|
||||
no_periodic_snapshot: false,
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use io::PanicHandler;
|
||||
use rpc_apis;
|
||||
use ethcore::client::Client;
|
||||
use ethsync::SyncProvider;
|
||||
use helpers::replace_home;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
@@ -49,6 +50,7 @@ pub struct Dependencies {
|
||||
pub panic_handler: Arc<PanicHandler>,
|
||||
pub apis: Arc<rpc_apis::Dependencies>,
|
||||
pub client: Arc<Client>,
|
||||
pub sync: Arc<SyncProvider>,
|
||||
}
|
||||
|
||||
pub fn new(configuration: Configuration, deps: Dependencies) -> Result<Option<WebappServer>, String> {
|
||||
@@ -117,9 +119,12 @@ mod server {
|
||||
) -> Result<WebappServer, String> {
|
||||
use ethcore_dapps as dapps;
|
||||
|
||||
let server = dapps::ServerBuilder::new(dapps_path, Arc::new(Registrar {
|
||||
client: deps.client.clone(),
|
||||
}));
|
||||
let mut server = dapps::ServerBuilder::new(
|
||||
dapps_path,
|
||||
Arc::new(Registrar { client: deps.client.clone() })
|
||||
);
|
||||
let sync = deps.sync.clone();
|
||||
server.with_sync_status(Arc::new(move || sync.status().is_major_syncing()));
|
||||
let server = rpc_apis::setup_rpc(server, deps.apis.clone(), rpc_apis::ApiSet::UnsafeContext);
|
||||
let start_result = match auth {
|
||||
None => {
|
||||
|
||||
@@ -99,9 +99,11 @@ mod modules;
|
||||
mod account;
|
||||
mod blockchain;
|
||||
mod presale;
|
||||
mod run;
|
||||
mod sync;
|
||||
mod snapshot;
|
||||
mod run;
|
||||
#[cfg(feature="ipc")]
|
||||
mod sync;
|
||||
#[cfg(feature="ipc")]
|
||||
mod boot;
|
||||
|
||||
#[cfg(feature="stratum")]
|
||||
@@ -158,10 +160,24 @@ mod stratum_optional {
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(feature="ipc"))]
|
||||
fn sync_main() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
#[cfg(feature="ipc")]
|
||||
fn sync_main() -> bool {
|
||||
// just redirect to the sync::main()
|
||||
if std::env::args().nth(1).map_or(false, |arg| arg == "sync") {
|
||||
sync::main();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if sync_main() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::sync::Arc;
|
||||
use ethcore::client::BlockChainClient;
|
||||
use hypervisor::Hypervisor;
|
||||
use ethsync::{SyncConfig, NetworkConfiguration, NetworkError};
|
||||
use ethcore::snapshot::SnapshotService;
|
||||
#[cfg(not(feature="ipc"))]
|
||||
use self::no_ipc_deps::*;
|
||||
#[cfg(feature="ipc")]
|
||||
@@ -25,10 +26,12 @@ use self::ipc_deps::*;
|
||||
use ethcore_logger::Config as LogConfig;
|
||||
use std::path::Path;
|
||||
|
||||
#[cfg(feature="ipc")]
|
||||
pub mod service_urls {
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const CLIENT: &'static str = "parity-chain.ipc";
|
||||
pub const SNAPSHOT: &'static str = "parity-snapshot.ipc";
|
||||
pub const SYNC: &'static str = "parity-sync.ipc";
|
||||
pub const SYNC_NOTIFY: &'static str = "parity-sync-notify.ipc";
|
||||
pub const NETWORK_MANAGER: &'static str = "parity-manage-net.ipc";
|
||||
@@ -119,6 +122,7 @@ pub fn sync
|
||||
sync_cfg: SyncConfig,
|
||||
net_cfg: NetworkConfiguration,
|
||||
_client: Arc<BlockChainClient>,
|
||||
_snapshot_service: Arc<SnapshotService>,
|
||||
log_settings: &LogConfig,
|
||||
)
|
||||
-> Result<SyncModules, NetworkError>
|
||||
@@ -148,10 +152,11 @@ pub fn sync
|
||||
sync_cfg: SyncConfig,
|
||||
net_cfg: NetworkConfiguration,
|
||||
client: Arc<BlockChainClient>,
|
||||
snapshot_service: Arc<SnapshotService>,
|
||||
_log_settings: &LogConfig,
|
||||
)
|
||||
-> Result<SyncModules, NetworkError>
|
||||
{
|
||||
let eth_sync = try!(EthSync::new(sync_cfg, client, net_cfg));
|
||||
let eth_sync = try!(EthSync::new(sync_cfg, client, snapshot_service, net_cfg));
|
||||
Ok((eth_sync.clone() as Arc<SyncProvider>, eth_sync.clone() as Arc<ManageNetwork>, eth_sync.clone() as Arc<ChainNotify>))
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ use ethcore::client::{Mode, Switch, DatabaseCompactionProfile, VMType, ChainNoti
|
||||
use ethcore::service::ClientService;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use ethcore::miner::{Miner, MinerService, ExternalMiner, MinerOptions};
|
||||
use ethcore::snapshot;
|
||||
use ethsync::SyncConfig;
|
||||
use informant::Informant;
|
||||
|
||||
@@ -46,6 +47,12 @@ use rpc_apis;
|
||||
use rpc;
|
||||
use url;
|
||||
|
||||
// how often to take periodic snapshots.
|
||||
const SNAPSHOT_PERIOD: u64 = 10000;
|
||||
|
||||
// how many blocks to wait before starting a periodic snapshot.
|
||||
const SNAPSHOT_HISTORY: u64 = 1000;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct RunCmd {
|
||||
pub cache_config: CacheConfig,
|
||||
@@ -77,6 +84,7 @@ pub struct RunCmd {
|
||||
pub ui: bool,
|
||||
pub name: String,
|
||||
pub custom_bootnodes: bool,
|
||||
pub no_periodic_snapshot: bool,
|
||||
}
|
||||
|
||||
pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
@@ -179,13 +187,14 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
|
||||
// take handle to client
|
||||
let client = service.client();
|
||||
let snapshot_service = service.snapshot_service();
|
||||
|
||||
// create external miner
|
||||
let external_miner = Arc::new(ExternalMiner::default());
|
||||
|
||||
// create sync object
|
||||
let (sync_provider, manage_network, chain_notify) = try!(modules::sync(
|
||||
&mut hypervisor, sync_config, net_conf.into(), client.clone(), &cmd.logger_config,
|
||||
&mut hypervisor, sync_config, net_conf.into(), client.clone(), snapshot_service, &cmd.logger_config,
|
||||
).map_err(|e| format!("Sync error: {}", e)));
|
||||
|
||||
service.add_notify(chain_notify.clone());
|
||||
@@ -224,6 +233,7 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
panic_handler: panic_handler.clone(),
|
||||
apis: deps_for_rpc_apis.clone(),
|
||||
client: client.clone(),
|
||||
sync: sync_provider.clone(),
|
||||
};
|
||||
|
||||
// start dapps server
|
||||
@@ -249,6 +259,22 @@ pub fn execute(cmd: RunCmd) -> Result<(), String> {
|
||||
});
|
||||
service.register_io_handler(io_handler).expect("Error registering IO handler");
|
||||
|
||||
// the watcher must be kept alive.
|
||||
let _watcher = match cmd.no_periodic_snapshot {
|
||||
true => None,
|
||||
false => {
|
||||
let watcher = Arc::new(snapshot::Watcher::new(
|
||||
service.client(),
|
||||
service.io().channel(),
|
||||
SNAPSHOT_PERIOD,
|
||||
SNAPSHOT_HISTORY,
|
||||
));
|
||||
|
||||
service.add_notify(watcher.clone());
|
||||
Some(watcher)
|
||||
},
|
||||
};
|
||||
|
||||
// start ui
|
||||
if cmd.ui {
|
||||
if !cmd.dapps_conf.enabled {
|
||||
|
||||
@@ -129,10 +129,9 @@ impl SnapshotCommand {
|
||||
|
||||
let informant_handle = snapshot.clone();
|
||||
::std::thread::spawn(move || {
|
||||
while let RestorationStatus::Ongoing = informant_handle.status() {
|
||||
let (state_chunks, block_chunks) = informant_handle.chunks_done();
|
||||
while let RestorationStatus::Ongoing { state_chunks_done, block_chunks_done } = informant_handle.status() {
|
||||
info!("Processed {}/{} state chunks and {}/{} block chunks.",
|
||||
state_chunks, num_state, block_chunks, num_blocks);
|
||||
state_chunks_done, num_state, block_chunks_done, num_blocks);
|
||||
|
||||
::std::thread::sleep(Duration::from_secs(5));
|
||||
}
|
||||
@@ -161,7 +160,7 @@ impl SnapshotCommand {
|
||||
}
|
||||
|
||||
match snapshot.status() {
|
||||
RestorationStatus::Ongoing => Err("Snapshot file is incomplete and missing chunks.".into()),
|
||||
RestorationStatus::Ongoing { .. } => Err("Snapshot file is incomplete and missing chunks.".into()),
|
||||
RestorationStatus::Failed => Err("Snapshot restoration failed.".into()),
|
||||
RestorationStatus::Inactive => {
|
||||
info!("Restoration complete.");
|
||||
|
||||
@@ -20,6 +20,7 @@ use std::sync::Arc;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use hypervisor::{SYNC_MODULE_ID, HYPERVISOR_IPC_URL, ControlService};
|
||||
use ethcore::client::{RemoteClient, ChainNotify};
|
||||
use ethcore::snapshot::{RemoteSnapshotService};
|
||||
use ethsync::{SyncProvider, EthSync, ManageNetwork, ServiceConfiguration};
|
||||
use modules::service_urls;
|
||||
use boot;
|
||||
@@ -45,8 +46,9 @@ pub fn main() {
|
||||
.unwrap_or_else(|e| panic!("Fatal: error reading boot arguments ({:?})", e));
|
||||
|
||||
let remote_client = dependency!(RemoteClient, &service_urls::with_base(&service_config.io_path, service_urls::CLIENT));
|
||||
let remote_snapshot = dependency!(RemoteSnapshotService, &service_urls::with_base(&service_config.io_path, service_urls::SNAPSHOT));
|
||||
|
||||
let sync = EthSync::new(service_config.sync, remote_client.service().clone(), service_config.net).unwrap();
|
||||
let sync = EthSync::new(service_config.sync, remote_client.service().clone(), remote_snapshot.service().clone(), service_config.net).unwrap();
|
||||
|
||||
let _ = boot::main_thread();
|
||||
let service_stop = Arc::new(AtomicBool::new(false));
|
||||
|
||||
Reference in New Issue
Block a user