Add preset command to parity CLI
Preset configs are loaded from bundled toml files and overridden by CLI options.
This commit is contained in:
parent
9c1030878e
commit
d4175ca6c6
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod usage;
|
mod usage;
|
||||||
|
mod presets;
|
||||||
use dir;
|
use dir;
|
||||||
|
|
||||||
usage! {
|
usage! {
|
||||||
@ -42,12 +43,14 @@ usage! {
|
|||||||
cmd_hash: bool,
|
cmd_hash: bool,
|
||||||
cmd_kill: bool,
|
cmd_kill: bool,
|
||||||
cmd_db: bool,
|
cmd_db: bool,
|
||||||
|
cmd_preset: bool,
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
arg_pid_file: String,
|
arg_pid_file: String,
|
||||||
arg_file: Option<String>,
|
arg_file: Option<String>,
|
||||||
arg_path: Vec<String>,
|
arg_path: Vec<String>,
|
||||||
arg_id: Option<usize>,
|
arg_id: Option<usize>,
|
||||||
|
arg_preset: String,
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
// -- Legacy Options
|
// -- Legacy Options
|
||||||
|
@ -1,146 +1,7 @@
|
|||||||
[parity]
|
[parity]
|
||||||
mode = "last"
|
mode = "dark"
|
||||||
mode_timeout = 300
|
chain = "kovan"
|
||||||
mode_alarm = 3600
|
|
||||||
auto_update = "none"
|
|
||||||
release_track = "current"
|
|
||||||
public_node = false
|
|
||||||
no_download = false
|
|
||||||
no_consensus = false
|
|
||||||
no_persistent_txqueue = false
|
|
||||||
|
|
||||||
chain = "homestead"
|
|
||||||
base_path = "$HOME/.parity"
|
|
||||||
db_path = "$HOME/.parity/chains"
|
|
||||||
keys_path = "$HOME/.parity/keys"
|
|
||||||
identity = ""
|
|
||||||
light = false
|
|
||||||
|
|
||||||
[account]
|
|
||||||
unlock = ["0xdeadbeefcafe0000000000000000000000000000"]
|
|
||||||
password = ["~/.safe/password.file"]
|
|
||||||
keys_iterations = 10240
|
|
||||||
|
|
||||||
[ui]
|
|
||||||
force = false
|
|
||||||
disable = false
|
|
||||||
port = 8180
|
|
||||||
interface = "127.0.0.1"
|
|
||||||
path = "$HOME/.parity/signer"
|
|
||||||
|
|
||||||
[network]
|
|
||||||
port = 30303
|
|
||||||
min_peers = 25
|
|
||||||
max_peers = 50
|
|
||||||
nat = "any"
|
|
||||||
id = 1
|
|
||||||
bootnodes = []
|
|
||||||
discovery = true
|
|
||||||
warp = true
|
|
||||||
allow_ips = "all"
|
|
||||||
snapshot_peers = 0
|
|
||||||
max_pending_peers = 64
|
|
||||||
no_serve_light = false
|
|
||||||
|
|
||||||
reserved_only = false
|
|
||||||
reserved_peers = "./path_to_file"
|
|
||||||
|
|
||||||
[rpc]
|
|
||||||
disable = false
|
|
||||||
port = 8545
|
|
||||||
interface = "local"
|
|
||||||
cors = "null"
|
|
||||||
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[websockets]
|
|
||||||
disable = false
|
|
||||||
port = 8546
|
|
||||||
interface = "local"
|
|
||||||
origins = ["none"]
|
|
||||||
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[ipc]
|
|
||||||
disable = false
|
|
||||||
path = "$HOME/.parity/jsonrpc.ipc"
|
|
||||||
apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "rpc", "secretstore"]
|
|
||||||
|
|
||||||
[dapps]
|
|
||||||
disable = false
|
|
||||||
port = 8080
|
|
||||||
interface = "local"
|
|
||||||
hosts = ["none"]
|
|
||||||
path = "$HOME/.parity/dapps"
|
|
||||||
# authorization:
|
|
||||||
user = "test_user"
|
|
||||||
pass = "test_pass"
|
|
||||||
|
|
||||||
[secretstore]
|
|
||||||
disable = false
|
|
||||||
nodes = []
|
|
||||||
http_interface = "local"
|
|
||||||
http_port = 8082
|
|
||||||
interface = "local"
|
|
||||||
port = 8083
|
|
||||||
path = "$HOME/.parity/secretstore"
|
|
||||||
|
|
||||||
[ipfs]
|
|
||||||
enable = false
|
|
||||||
port = 5001
|
|
||||||
interface = "local"
|
|
||||||
cors = "null"
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[mining]
|
[mining]
|
||||||
author = "0xdeadbeefcafe0000000000000000000000000001"
|
|
||||||
engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
|
||||||
force_sealing = true
|
force_sealing = true
|
||||||
reseal_on_txs = "all"
|
reseal_min_period = 2000
|
||||||
reseal_min_period = 4000
|
|
||||||
reseal_max_period = 60000
|
|
||||||
work_queue_size = 20
|
|
||||||
relay_set = "cheap"
|
|
||||||
usd_per_tx = "0.0025"
|
|
||||||
usd_per_eth = "auto"
|
|
||||||
price_update_period = "hourly"
|
|
||||||
gas_floor_target = "4700000"
|
|
||||||
gas_cap = "6283184"
|
|
||||||
tx_queue_size = 1024
|
|
||||||
tx_queue_gas = "auto"
|
|
||||||
tx_queue_strategy = "gas_factor"
|
|
||||||
tx_queue_ban_count = 1
|
|
||||||
tx_queue_ban_time = 180 #s
|
|
||||||
tx_gas_limit = "6283184"
|
|
||||||
tx_time_limit = 100 #ms
|
|
||||||
extra_data = "Parity"
|
|
||||||
remove_solved = false
|
|
||||||
notify_work = ["http://localhost:3001"]
|
|
||||||
refuse_service_transactions = false
|
|
||||||
|
|
||||||
[footprint]
|
|
||||||
tracing = "auto"
|
|
||||||
pruning = "auto"
|
|
||||||
pruning_history = 64
|
|
||||||
pruning_memory = 500
|
|
||||||
cache_size_db = 64
|
|
||||||
cache_size_blocks = 8
|
|
||||||
cache_size_queue = 50
|
|
||||||
cache_size_state = 25
|
|
||||||
cache_size = 128 # Overrides above caches with total size
|
|
||||||
fast_and_loose = false
|
|
||||||
db_compaction = "ssd"
|
|
||||||
fat_db = "auto"
|
|
||||||
scale_verifiers = true
|
|
||||||
num_verifiers = 6
|
|
||||||
|
|
||||||
[snapshots]
|
|
||||||
disable_periodic = false
|
|
||||||
|
|
||||||
[vm]
|
|
||||||
jit = false
|
|
||||||
|
|
||||||
[misc]
|
|
||||||
logging = "own_tx=trace"
|
|
||||||
log_file = "/var/log/parity.log"
|
|
||||||
color = true
|
|
@ -1,146 +1,3 @@
|
|||||||
[parity]
|
[parity]
|
||||||
mode = "last"
|
mode = "passive"
|
||||||
mode_timeout = 300
|
chain = "homestead"
|
||||||
mode_alarm = 3600
|
|
||||||
auto_update = "none"
|
|
||||||
release_track = "current"
|
|
||||||
public_node = false
|
|
||||||
no_download = false
|
|
||||||
no_consensus = false
|
|
||||||
no_persistent_txqueue = false
|
|
||||||
|
|
||||||
chain = "homestead"
|
|
||||||
base_path = "$HOME/.parity"
|
|
||||||
db_path = "$HOME/.parity/chains"
|
|
||||||
keys_path = "$HOME/.parity/keys"
|
|
||||||
identity = ""
|
|
||||||
light = false
|
|
||||||
|
|
||||||
[account]
|
|
||||||
unlock = ["0xdeadbeefcafe0000000000000000000000000000"]
|
|
||||||
password = ["~/.safe/password.file"]
|
|
||||||
keys_iterations = 10240
|
|
||||||
|
|
||||||
[ui]
|
|
||||||
force = false
|
|
||||||
disable = false
|
|
||||||
port = 8180
|
|
||||||
interface = "127.0.0.1"
|
|
||||||
path = "$HOME/.parity/signer"
|
|
||||||
|
|
||||||
[network]
|
|
||||||
port = 30303
|
|
||||||
min_peers = 25
|
|
||||||
max_peers = 50
|
|
||||||
nat = "any"
|
|
||||||
id = 1
|
|
||||||
bootnodes = []
|
|
||||||
discovery = true
|
|
||||||
warp = true
|
|
||||||
allow_ips = "all"
|
|
||||||
snapshot_peers = 0
|
|
||||||
max_pending_peers = 64
|
|
||||||
no_serve_light = false
|
|
||||||
|
|
||||||
reserved_only = false
|
|
||||||
reserved_peers = "./path_to_file"
|
|
||||||
|
|
||||||
[rpc]
|
|
||||||
disable = false
|
|
||||||
port = 8545
|
|
||||||
interface = "local"
|
|
||||||
cors = "null"
|
|
||||||
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[websockets]
|
|
||||||
disable = false
|
|
||||||
port = 8546
|
|
||||||
interface = "local"
|
|
||||||
origins = ["none"]
|
|
||||||
apis = ["web3", "eth", "net", "parity", "traces", "rpc", "secretstore"]
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[ipc]
|
|
||||||
disable = false
|
|
||||||
path = "$HOME/.parity/jsonrpc.ipc"
|
|
||||||
apis = ["web3", "eth", "net", "parity", "parity_accounts", "personal", "traces", "rpc", "secretstore"]
|
|
||||||
|
|
||||||
[dapps]
|
|
||||||
disable = false
|
|
||||||
port = 8080
|
|
||||||
interface = "local"
|
|
||||||
hosts = ["none"]
|
|
||||||
path = "$HOME/.parity/dapps"
|
|
||||||
# authorization:
|
|
||||||
user = "test_user"
|
|
||||||
pass = "test_pass"
|
|
||||||
|
|
||||||
[secretstore]
|
|
||||||
disable = false
|
|
||||||
nodes = []
|
|
||||||
http_interface = "local"
|
|
||||||
http_port = 8082
|
|
||||||
interface = "local"
|
|
||||||
port = 8083
|
|
||||||
path = "$HOME/.parity/secretstore"
|
|
||||||
|
|
||||||
[ipfs]
|
|
||||||
enable = false
|
|
||||||
port = 5001
|
|
||||||
interface = "local"
|
|
||||||
cors = "null"
|
|
||||||
hosts = ["none"]
|
|
||||||
|
|
||||||
[mining]
|
|
||||||
author = "0xdeadbeefcafe0000000000000000000000000001"
|
|
||||||
engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
|
||||||
force_sealing = true
|
|
||||||
reseal_on_txs = "all"
|
|
||||||
reseal_min_period = 4000
|
|
||||||
reseal_max_period = 60000
|
|
||||||
work_queue_size = 20
|
|
||||||
relay_set = "cheap"
|
|
||||||
usd_per_tx = "0.0025"
|
|
||||||
usd_per_eth = "auto"
|
|
||||||
price_update_period = "hourly"
|
|
||||||
gas_floor_target = "4700000"
|
|
||||||
gas_cap = "6283184"
|
|
||||||
tx_queue_size = 1024
|
|
||||||
tx_queue_gas = "auto"
|
|
||||||
tx_queue_strategy = "gas_factor"
|
|
||||||
tx_queue_ban_count = 1
|
|
||||||
tx_queue_ban_time = 180 #s
|
|
||||||
tx_gas_limit = "6283184"
|
|
||||||
tx_time_limit = 100 #ms
|
|
||||||
extra_data = "Parity"
|
|
||||||
remove_solved = false
|
|
||||||
notify_work = ["http://localhost:3001"]
|
|
||||||
refuse_service_transactions = false
|
|
||||||
|
|
||||||
[footprint]
|
|
||||||
tracing = "auto"
|
|
||||||
pruning = "auto"
|
|
||||||
pruning_history = 64
|
|
||||||
pruning_memory = 500
|
|
||||||
cache_size_db = 64
|
|
||||||
cache_size_blocks = 8
|
|
||||||
cache_size_queue = 50
|
|
||||||
cache_size_state = 25
|
|
||||||
cache_size = 128 # Overrides above caches with total size
|
|
||||||
fast_and_loose = false
|
|
||||||
db_compaction = "ssd"
|
|
||||||
fat_db = "auto"
|
|
||||||
scale_verifiers = true
|
|
||||||
num_verifiers = 6
|
|
||||||
|
|
||||||
[snapshots]
|
|
||||||
disable_periodic = false
|
|
||||||
|
|
||||||
[vm]
|
|
||||||
jit = false
|
|
||||||
|
|
||||||
[misc]
|
|
||||||
logging = "own_tx=trace"
|
|
||||||
log_file = "/var/log/parity.log"
|
|
||||||
color = true
|
|
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Parity.
|
||||||
|
|
||||||
|
// Parity is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Parity is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
pub fn preset_config_string(arg: &str) -> Result<&'static str, &str> {
|
||||||
|
match arg.to_lowercase().as_ref() {
|
||||||
|
"poa" => Ok(include_str!("./config.poa.toml")),
|
||||||
|
"pow" => Ok(include_str!("./config.pow.toml")),
|
||||||
|
_ => Err(arg.clone())
|
||||||
|
}
|
||||||
|
}
|
@ -61,6 +61,7 @@ macro_rules! usage {
|
|||||||
Docopt(DocoptError),
|
Docopt(DocoptError),
|
||||||
Decode(toml::de::Error),
|
Decode(toml::de::Error),
|
||||||
Config(String, io::Error),
|
Config(String, io::Error),
|
||||||
|
Preset(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ArgsError {
|
impl ArgsError {
|
||||||
@ -77,6 +78,10 @@ macro_rules! usage {
|
|||||||
println_stderr!("{}", e);
|
println_stderr!("{}", e);
|
||||||
process::exit(2)
|
process::exit(2)
|
||||||
},
|
},
|
||||||
|
ArgsError::Preset(a) => {
|
||||||
|
println_stderr!("Invalid preset argument: {}", a);
|
||||||
|
process::exit(2)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,22 +154,29 @@ macro_rules! usage {
|
|||||||
return Ok(raw_args.into_args(Config::default()));
|
return Ok(raw_args.into_args(Config::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let config_file = raw_args.flag_config.clone().unwrap_or_else(|| raw_args.clone().into_args(Config::default()).flag_config);
|
let config = if raw_args.cmd_preset {
|
||||||
let config_file = replace_home(&::dir::default_data_path(), &config_file);
|
match presets::preset_config_string(&raw_args.arg_preset) {
|
||||||
let config = match (fs::File::open(&config_file), raw_args.flag_config.is_some()) {
|
Ok(s) => Self::parse_config(&s)?,
|
||||||
// Load config file
|
Err(e) => return Err(ArgsError::Preset(e.to_string()))
|
||||||
(Ok(mut file), _) => {
|
}
|
||||||
println_stderr!("Loading config file from {}", &config_file);
|
} else {
|
||||||
let mut config = String::new();
|
let config_file = raw_args.flag_config.clone().unwrap_or_else(|| raw_args.clone().into_args(Config::default()).flag_config);
|
||||||
file.read_to_string(&mut config).map_err(|e| ArgsError::Config(config_file, e))?;
|
let config_file = replace_home(&::dir::default_data_path(), &config_file);
|
||||||
Self::parse_config(&config)?
|
match (fs::File::open(&config_file), raw_args.flag_config.is_some()) {
|
||||||
},
|
// Load config file
|
||||||
// Don't display error in case default config cannot be loaded.
|
(Ok(mut file), _) => {
|
||||||
(Err(_), false) => Config::default(),
|
println_stderr!("Loading config file from {}", &config_file);
|
||||||
// Config set from CLI (fail with error)
|
let mut config = String::new();
|
||||||
(Err(e), true) => {
|
file.read_to_string(&mut config).map_err(|e| ArgsError::Config(config_file, e))?;
|
||||||
return Err(ArgsError::Config(config_file, e));
|
Self::parse_config(&config)?
|
||||||
},
|
},
|
||||||
|
// Don't display error in case default config cannot be loaded.
|
||||||
|
(Err(_), false) => Config::default(),
|
||||||
|
// Config set from CLI (fail with error)
|
||||||
|
(Err(e), true) => {
|
||||||
|
return Err(ArgsError::Config(config_file, e));
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(raw_args.into_args(config))
|
Ok(raw_args.into_args(config))
|
||||||
|
@ -20,6 +20,7 @@ Usage:
|
|||||||
parity restore [ <file> ] [options]
|
parity restore [ <file> ] [options]
|
||||||
parity tools hash <file>
|
parity tools hash <file>
|
||||||
parity db kill [options]
|
parity db kill [options]
|
||||||
|
parity preset <preset> [options]
|
||||||
|
|
||||||
Operating Options:
|
Operating Options:
|
||||||
--mode MODE Set the operating mode. MODE can be one of:
|
--mode MODE Set the operating mode. MODE can be one of:
|
||||||
|
Loading…
Reference in New Issue
Block a user