diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index bbd5e0cff..5f062d425 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -119,8 +119,8 @@ usage! { flag_ui_no_validation: bool = false, or |_| None, // -- Networking Options - flag_warp: bool = false, - or |c: &Config| otry!(c.network).warp.clone(), + flag_no_warp: bool = false, + or |c: &Config| otry!(c.network).warp.clone().map(|w| !w), flag_port: u16 = 30303u16, or |c: &Config| otry!(c.network).port.clone(), flag_min_peers: u16 = 25u16, @@ -330,6 +330,7 @@ usage! { // Values with optional default value. flag_base_path: Option, display dir::default_data_path(), or |c: &Config| otry!(c.parity).base_path.clone().map(Some), flag_db_path: Option, display dir::CHAINS_PATH, or |c: &Config| otry!(c.parity).db_path.clone().map(Some), + flag_warp: Option, display true, or |c: &Config| Some(otry!(c.network).warp.clone()), } } @@ -638,7 +639,7 @@ mod tests { flag_ui_no_validation: false, // -- Networking Options - flag_warp: true, + flag_no_warp: false, flag_port: 30303u16, flag_min_peers: 25u16, flag_max_peers: 50u16, @@ -779,6 +780,7 @@ mod tests { flag_etherbase: None, flag_extradata: None, flag_cache: None, + flag_warp: Some(true), // -- Miscellaneous Options flag_version: false, diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index dee6dd788..01a7b87bd 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -97,7 +97,7 @@ UI Options: development. (default: {flag_ui_no_validation}) Networking Options: - --warp Enable syncing from the snapshot over the network. (default: {flag_warp}) + --no-warp Disable syncing from the snapshot over the network. (default: {flag_no_warp}) --port PORT Override the port on which the node should listen (default: {flag_port}). --min-peers NUM Try to maintain at least NUM peers (default: {flag_min_peers}). @@ -386,6 +386,7 @@ Legacy Options: -w --webapp Does nothing; dapps server is on by default now. --dapps-off Equivalent to --no-dapps. --rpc Does nothing; JSON-RPC is on by default now. + --warp Does nothing; Warp sync is on by default. (default: {flag_warp}) --rpcaddr IP Equivalent to --jsonrpc-interface IP. --rpcport PORT Equivalent to --jsonrpc-port PORT. --rpcapi APIS Equivalent to --jsonrpc-apis APIS. diff --git a/parity/configuration.rs b/parity/configuration.rs index 8a5c64920..6ef3bc660 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -15,12 +15,13 @@ // along with Parity. If not, see . use std::time::Duration; -use std::io::Read; +use std::io::{Read, Write, stderr}; use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::cmp::max; use cli::{Args, ArgsError}; use util::{Hashable, H256, U256, Uint, Bytes, version_data, Address}; +use util::journaldb::Algorithm; use util::log::Colour; use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP}; use ethcore::ethstore::ethkey::Secret; @@ -33,7 +34,7 @@ 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, replace_home_for_db, geth_ipc_path, parity_ipc_path, to_bootnodes, to_addresses, to_address, to_gas_limit, to_queue_strategy}; -use params::{SpecType, ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras}; +use params::{SpecType, ResealPolicy, AccountsConfig, GasPricerConfig, MinerExtras, Pruning, Switch}; use ethcore_logger::Config as LogConfig; use dir::{self, Directories, default_hypervisor_path, default_local_path, default_data_path}; use dapps::Configuration as DappsConfiguration; @@ -115,7 +116,14 @@ impl Configuration { let fat_db = self.args.flag_fat_db.parse()?; let compaction = self.args.flag_db_compaction.parse()?; let wal = !self.args.flag_fast_and_loose; - let warp_sync = self.args.flag_warp; + match self.args.flag_warp { + // Logging is not initialized yet, so we print directly to stderr + Some(true) if fat_db == Switch::On => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because Fat DB is turned on").expect("Error writing to stderr"), + Some(true) if tracing == Switch::On => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because tracing is turned on").expect("Error writing to stderr"), + Some(true) if pruning == Pruning::Specific(Algorithm::Archive) => writeln!(&mut stderr(), "Warning: Warp Sync is disabled because pruning mode is set to archive").expect("Error writing to stderr"), + _ => {}, + }; + let warp_sync = !self.args.flag_no_warp && fat_db != Switch::On && tracing != Switch::On && pruning != Pruning::Specific(Algorithm::Archive); let geth_compatibility = self.args.flag_geth; let ui_address = self.ui_port().map(|port| (self.ui_interface(), port)); let dapps_conf = self.dapps_config(); @@ -1144,7 +1152,7 @@ mod tests { ipc_conf: Default::default(), net_conf: default_network_config(), network_id: None, - warp_sync: false, + warp_sync: true, acc_conf: Default::default(), gas_pricer: Default::default(), miner_extras: Default::default(),