Reduce duplication of keypair generation

This commit is contained in:
Paul Hauner
2019-11-24 07:42:13 +11:00
parent e94c265036
commit 07681612d0
4 changed files with 34 additions and 32 deletions

View File

@@ -1,6 +1,5 @@
use clap::ArgMatches;
use serde_derive::{Deserialize, Serialize};
use std::ops::Range;
use std::path::PathBuf;
pub const DEFAULT_HTTP_SERVER: &str = "http://localhost:5052/";
@@ -11,7 +10,7 @@ pub enum KeySource {
/// Load the keypairs from disk.
Disk,
/// Generate the keypairs (insecure, generates predictable keys).
TestingKeypairRange(Range<usize>),
InsecureKeypairs(Vec<usize>),
}
impl Default for KeySource {
@@ -93,7 +92,7 @@ fn process_testnet_subcommand(cli_args: &ArgMatches, mut config: Config) -> Resu
return Err("Cannot supply a last validator less than the first".to_string());
}
KeySource::TestingKeypairRange(first..last)
KeySource::InsecureKeypairs((first..last).collect())
}
_ => KeySource::Disk,
};