Add slot-time CLI argument

This commit is contained in:
Paul Hauner 2019-09-02 10:22:29 +10:00
parent 4aa12dc408
commit 82dc84ebbf
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
2 changed files with 24 additions and 1 deletions

View File

@ -74,7 +74,7 @@ fn process_testnet_subcommand(
if let Some(path_string) = cli_args.value_of("eth2-config") {
if is_bootstrap {
return Err("Cannot supply --eth2-config when using bootsrap".to_string());
return Err("Cannot supply --eth2-config when using bootstrap".to_string());
}
let path = path_string
@ -85,6 +85,18 @@ fn process_testnet_subcommand(
builder.update_spec_from_subcommand(&cli_args)?;
}
if let Some(slot_time) = cli_args.value_of("slot-time") {
if is_bootstrap {
return Err("Cannot supply --slot-time flag whilst using bootstrap.".into());
}
let slot_time = slot_time
.parse::<u64>()
.map_err(|e| format!("Unable to parse slot-time: {:?}", e))?;
builder.set_slot_time(slot_time);
}
if let Some(path_string) = cli_args.value_of("client-config") {
let path = path_string
.parse::<PathBuf>()
@ -307,6 +319,10 @@ impl<'a> ConfigBuilder<'a> {
self.eth2_config = eth2_config;
}
fn set_slot_time(&mut self, milliseconds_per_slot: u64) {
self.eth2_config.spec.milliseconds_per_slot = milliseconds_per_slot;
}
/// Reads the subcommand and tries to update `self.eth2_config` based up on the `--spec` flag.
///
/// Returns an error if the `--spec` flag is not present in the given `cli_args`.

View File

@ -241,6 +241,13 @@ fn main() {
backup directory.")
.conflicts_with("random-datadir")
)
.arg(
Arg::with_name("slot-time")
.long("slot-time")
.short("t")
.value_name("MILLISECONDS")
.help("Defines the slot time when creating a new testnet.")
)
/*
* `boostrap`
*