From 9d3b2352cca5386de0da28b9a2433e32d448843e Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 23 Nov 2016 16:29:15 +0100 Subject: [PATCH] More work. --- ethcore/src/client/client.rs | 3 ++- ethcore/src/client/config.rs | 29 +++++++++++++++++++++++++++++ ethcore/src/client/mod.rs | 2 +- ethcore/src/client/updater.rs | 2 ++ parity/cli/mod.rs | 2 ++ parity/cli/usage.txt | 19 +++++++++++-------- parity/configuration.rs | 6 +++++- 7 files changed, 52 insertions(+), 11 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index a4fa5aa57..102c4aab6 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -54,7 +54,7 @@ use blockchain::{BlockChain, BlockProvider, TreeRoute, ImportRoute}; use client::{ BlockId, TransactionId, UncleId, TraceId, ClientConfig, BlockChainClient, MiningBlockChainClient, TraceFilter, CallAnalytics, BlockImportError, Mode, - ChainNotify, + ChainNotify, UpdatePolicy, }; use client::Error as ClientError; use env_info::EnvInfo; @@ -129,6 +129,7 @@ impl SleepState { /// Call `import_block()` to import a block asynchronously; `flush_queue()` flushes the queue. pub struct Client { mode: Mutex, + update_policy: UpdatePolicy, chain: RwLock>, tracedb: RwLock>, engine: Arc, diff --git a/ethcore/src/client/config.rs b/ethcore/src/client/config.rs index 045b8ee05..bf06df462 100644 --- a/ethcore/src/client/config.rs +++ b/ethcore/src/client/config.rs @@ -66,6 +66,35 @@ impl FromStr for DatabaseCompactionProfile { } } +#[derive(Debug, Eq, PartialEq, Clone)] +pub enum UpdateFilter { + All, + Patch, + Critical, + None, +} + +#[derive(Debug, Eq, PartialEq, Clone)] +pub struct UpdatePolicy { + download_only: bool, + track: Track, +} + +/// Operating mode for the client. +#[derive(Debug, Eq, PartialEq, Clone)] +pub enum UpdatePolicy { + /// Always on. + Active, + /// Goes offline after RLP is inactive for some (given) time, but + /// comes back online after a while of inactivity. + Passive(Duration, Duration), + /// Goes offline after RLP is inactive for some (given) time and + /// stays inactive. + Dark(Duration), + /// Always off. + Off, +} + /// Operating mode for the client. #[derive(Debug, Eq, PartialEq, Clone)] pub enum Mode { diff --git a/ethcore/src/client/mod.rs b/ethcore/src/client/mod.rs index b49301bbd..adeaaf64a 100644 --- a/ethcore/src/client/mod.rs +++ b/ethcore/src/client/mod.rs @@ -26,7 +26,7 @@ mod client; mod updater; pub use self::client::*; -pub use self::config::{Mode, ClientConfig, DatabaseCompactionProfile, BlockChainConfig, VMType}; +pub use self::config::{Mode, ClientConfig, UpdatePolicy, Automation, DatabaseCompactionProfile, BlockChainConfig, VMType}; pub use self::error::Error; pub use types::ids::*; pub use self::test_client::{TestBlockChainClient, EachBlockWith}; diff --git a/ethcore/src/client/updater.rs b/ethcore/src/client/updater.rs index 211fdeb1f..dc45a55ff 100644 --- a/ethcore/src/client/updater.rs +++ b/ethcore/src/client/updater.rs @@ -34,6 +34,8 @@ pub struct Updater { client: Weak, operations: Operations, + + pub this: VersionInfo, pub release_info: Option, diff --git a/parity/cli/mod.rs b/parity/cli/mod.rs index 3ad6259b8..33a48b3b0 100644 --- a/parity/cli/mod.rs +++ b/parity/cli/mod.rs @@ -77,6 +77,7 @@ usage! { flag_mode: String = "last", or |c: &Config| otry!(c.parity).mode.clone(), flag_mode_timeout: u64 = 300u64, or |c: &Config| otry!(c.parity).mode_timeout.clone(), flag_mode_alarm: u64 = 3600u64, or |c: &Config| otry!(c.parity).mode_alarm.clone(), + flag_auto_update: String = "consensus", or |c: &Config| otry!(c.parity).auto_update.clone(), flag_chain: String = "homestead", or |c: &Config| otry!(c.parity).chain.clone(), flag_db_path: String = "$HOME/.parity", or |c: &Config| otry!(c.parity).db_path.clone(), flag_keys_path: String = "$HOME/.parity/keys", or |c: &Config| otry!(c.parity).keys_path.clone(), @@ -501,6 +502,7 @@ mod tests { flag_mode: "last".into(), flag_mode_timeout: 300u64, flag_mode_alarm: 3600u64, + flag_auto_update: "consensus".into(), flag_chain: "xyz".into(), flag_db_path: "$HOME/.parity".into(), flag_keys_path: "$HOME/.parity/keys".into(), diff --git a/parity/cli/usage.txt b/parity/cli/usage.txt index e12a2566e..0ac59da0e 100644 --- a/parity/cli/usage.txt +++ b/parity/cli/usage.txt @@ -24,20 +24,23 @@ Operating Options: wakes regularly to resync. dark - Parity syncs only when the RPC is active. offline - Parity doesn't sync. (default: {flag_mode}). - --updates POLICY Set the client updating policy. POLICY specifies - which updates Parity will auto-install: - track - All updates in the current release track. - patch - All updates of the current minor version. - critical - Only consensus/security updates. - none - No updates. Not recommended. - --no-consensus Force the binary to run even if there are known - issues regarding consensus. Not recommended. --mode-timeout SECS Specify the number of seconds before inactivity timeout occurs when mode is dark or passive (default: {flag_mode_timeout}). --mode-alarm SECS Specify the number of seconds before auto sleep reawake timeout occurs when mode is passive (default: {flag_mode_alarm}). + --auto-update TRACK Set a release track to automatically update and + install. + all - All updates in the current release track. + patch - All updates of the current minor version. + critical - Only consensus/security updates. + none - No updates will be auto-installed. + (default: {flag_auto_update}). + --no-download Normally new releases will be downloaded ready for + updating. This disables it. Not recommended. + --no-consensus Force the binary to run even if there are known + issues regarding consensus. Not recommended. --chain CHAIN Specify the blockchain type. CHAIN may be either a JSON chain specification file or olympic, frontier, homestead, mainnet, morden, ropsten, classic, expanse, diff --git a/parity/configuration.rs b/parity/configuration.rs index a51d12273..e08c853bd 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -23,7 +23,7 @@ use cli::{Args, ArgsError}; use util::{Hashable, U256, Uint, Bytes, version_data, Secret, Address}; use util::log::Colour; use ethsync::{NetworkConfiguration, is_valid_node_url, AllowIP}; -use ethcore::client::VMType; +use ethcore::client::{VMType, UpdatePolicy}; use ethcore::miner::{MinerOptions, Banning}; use rpc::{IpcConfiguration, HttpConfiguration}; @@ -585,6 +585,10 @@ impl Configuration { } } + fn update_policy(&self) -> UpdatePolicy { + + } + fn directories(&self) -> Directories { use util::path;