Make accounts refresh time configurable. (#7345)

* Configurable accounts refresh time.

* Fix tests.
This commit is contained in:
Tomasz Drwięga
2017-12-22 04:33:49 +01:00
committed by Svyatoslav Nikolsky
parent 276496fb4b
commit 83447c201b
5 changed files with 67 additions and 20 deletions

View File

@@ -335,6 +335,10 @@ usage! {
"--keys-iterations=[NUM]",
"Specify the number of iterations to use when deriving key from the password (bigger is more secure)",
ARG arg_accounts_refresh: (u64) = 5u64, or |c: &Config| otry!(c.account).refresh_time.clone(),
"--accounts-refresh=[TIME]",
"Specify the cache time of accounts read from disk. If you manage thousands of accounts set this to 0 to disable refresh.",
ARG arg_unlock: (Option<String>) = None, or |c: &Config| otry!(c.account).unlock.as_ref().map(|vec| vec.join(",")),
"--unlock=[ACCOUNTS]",
"Unlock ACCOUNTS for the duration of the execution. ACCOUNTS is a comma-delimited list of addresses. Implies --no-ui.",
@@ -1009,6 +1013,7 @@ struct Account {
unlock: Option<Vec<String>>,
password: Option<Vec<String>>,
keys_iterations: Option<u32>,
refresh_time: Option<u64>,
disable_hardware: Option<bool>,
fast_unlock: Option<bool>,
}
@@ -1428,6 +1433,7 @@ mod tests {
arg_unlock: Some("0xdeadbeefcafe0000000000000000000000000000".into()),
arg_password: vec!["~/.safe/password.file".into()],
arg_keys_iterations: 10240u32,
arg_accounts_refresh: 5u64,
flag_no_hardware_wallets: false,
flag_fast_unlock: false,
@@ -1665,6 +1671,7 @@ mod tests {
unlock: Some(vec!["0x1".into(), "0x2".into(), "0x3".into()]),
password: Some(vec!["passwdfile path".into()]),
keys_iterations: None,
refresh_time: None,
disable_hardware: None,
fast_unlock: None,
}),