From 4fea18d9454d9100a16df08fbeadadb61e62c4bc Mon Sep 17 00:00:00 2001 From: Joseph Mark Date: Fri, 14 Jul 2017 10:15:39 +0700 Subject: [PATCH] Add mining preset and test --- parity/cli/presets/config.mining.toml | 34 +++++++++++++++++++++++++++ parity/cli/presets/config.poa.toml | 7 ------ parity/cli/presets/config.pow.toml | 3 --- parity/cli/presets/mod.rs | 1 + parity/configuration.rs | 22 +++++++++++++++++ 5 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 parity/cli/presets/config.mining.toml delete mode 100644 parity/cli/presets/config.poa.toml delete mode 100644 parity/cli/presets/config.pow.toml diff --git a/parity/cli/presets/config.mining.toml b/parity/cli/presets/config.mining.toml new file mode 100644 index 000000000..f059fe30e --- /dev/null +++ b/parity/cli/presets/config.mining.toml @@ -0,0 +1,34 @@ +# This config should be placed in following path: +# $HOME/Library/Application Support/io.parity.ethereum/config.toml + +[network] +# Parity will try to maintain connection to at least 50 peers. +min_peers = 50 +# Parity will maintain at most 100 peers. +max_peers = 100 + +[ipc] +# You won't be able to use IPC to interact with Parity. +disable = true + +[dapps] +# You won't be able to access any web Dapps. +disable = true + +[mining] +# Prepare a block to seal even when there are no miners connected. +force_sealing = true +# New pending block will be created for all transactions (both local and external). +reseal_on_txs = "all" +# New pending block will be created only once per 4000 milliseconds. +reseal_min_period = 4000 +# Parity will keep/relay at most 2048 transactions in queue. +tx_queue_size = 2048 + +[footprint] +# If defined will never use more then 256MB for all caches. (Overrides other cache settings). +cache_size = 256 + +[misc] +# Logging pattern (`=`, e.g. `own_tx=trace`). +logging = "miner=trace,own_tx=trace" \ No newline at end of file diff --git a/parity/cli/presets/config.poa.toml b/parity/cli/presets/config.poa.toml deleted file mode 100644 index af245fdb0..000000000 --- a/parity/cli/presets/config.poa.toml +++ /dev/null @@ -1,7 +0,0 @@ -[parity] -mode = "dark" -chain = "kovan" - -[mining] -force_sealing = true -reseal_min_period = 2000 \ No newline at end of file diff --git a/parity/cli/presets/config.pow.toml b/parity/cli/presets/config.pow.toml deleted file mode 100644 index a3001e727..000000000 --- a/parity/cli/presets/config.pow.toml +++ /dev/null @@ -1,3 +0,0 @@ -[parity] -mode = "passive" -chain = "homestead" \ No newline at end of file diff --git a/parity/cli/presets/mod.rs b/parity/cli/presets/mod.rs index 5b38ea0cb..1242a7e88 100644 --- a/parity/cli/presets/mod.rs +++ b/parity/cli/presets/mod.rs @@ -17,6 +17,7 @@ pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> { match arg.to_lowercase().as_ref() { "dev" => Ok(include_str!("./config.dev.toml")), + "mining" => Ok(include_str!("./config.mining.toml")), _ => Err(arg.clone()) } } \ No newline at end of file diff --git a/parity/configuration.rs b/parity/configuration.rs index 4932b3bfd..4ca5fb1e3 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -1594,6 +1594,28 @@ mod tests { } } + #[test] + fn test_mining_preset() { + let args = vec!["parity", "preset", "mining"]; + let conf = Configuration::parse(&args, None).unwrap(); + match conf.into_command().unwrap().cmd { + Cmd::Run(c) => { + assert_eq!(c.net_conf.min_peers, 50); + assert_eq!(c.net_conf.max_peers, 100); + assert_eq!(c.ipc_conf.enabled, false); + assert_eq!(c.dapps_conf.enabled, false); + assert_eq!(c.miner_options.force_sealing, true); + assert_eq!(c.miner_options.reseal_on_external_tx, true); + assert_eq!(c.miner_options.reseal_on_own_tx, true); + assert_eq!(c.miner_options.reseal_min_period, Duration::from_millis(4000)); + assert_eq!(c.miner_options.tx_queue_size, 2048); + assert_eq!(c.cache_config, CacheConfig::new_with_total_cache_size(256)); + assert_eq!(c.logger_config.mode.unwrap(), "miner=trace,own_tx=trace"); + }, + _ => panic!("Should be Cmd::Run"), + } + } + #[test] fn should_apply_ports_shift() { // given