Remove validators subcommand

This commit is contained in:
Paul Hauner
2022-12-01 10:35:51 +11:00
parent 06f7efcc58
commit 0ece17ed32
6 changed files with 17 additions and 46 deletions

View File

@@ -1,12 +1,15 @@
use clap::App;
use clap::ArgMatches;
use common::write_to_json_file;
use environment::Environment;
use serde::Serialize;
use std::path::PathBuf;
use types::EthSpec;
use validators::common::write_to_json_file;
pub mod validators;
pub mod common;
pub mod create_validators;
pub mod import_validators;
pub mod move_validators;
pub const CMD: &str = "validator_manager";
@@ -39,7 +42,9 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::new(CMD)
.visible_aliases(&["vm", "validator-manager", CMD])
.about("Utilities for managing a Lighthouse validator client via the HTTP API.")
.subcommand(validators::cli_app())
.subcommand(create_validators::cli_app())
.subcommand(import_validators::cli_app())
.subcommand(move_validators::cli_app())
}
/// Run the account manager, returning an error if the operation did not succeed.
@@ -58,8 +63,14 @@ pub fn run<'a, T: EthSpec>(matches: &'a ArgMatches<'a>, env: Environment<T>) ->
.block_on_dangerous(
async {
match matches.subcommand() {
(validators::CMD, Some(matches)) => {
validators::cli_run::<T>(matches, &spec, dump_config).await
(create_validators::CMD, Some(matches)) => {
create_validators::cli_run::<T>(matches, &spec, dump_config).await
}
(import_validators::CMD, Some(matches)) => {
import_validators::cli_run(matches, dump_config).await
}
(move_validators::CMD, Some(matches)) => {
move_validators::cli_run(matches, dump_config).await
}
("", _) => Err("No command supplied. See --help.".to_string()),
(unknown, _) => Err(format!(

View File

@@ -234,7 +234,7 @@ async fn run<'a>(config: MoveConfig) -> Result<(), String> {
.filter(|v| !v.readonly.unwrap_or(true))
.map(|v| v.validating_pubkey)
.collect();
viable_pubkeys.sort_unstable_by_key(|pubkey| pubkey.serialize());
viable_pubkeys.sort_unstable_by_key(PublicKeyBytes::serialize);
viable_pubkeys
.get(0..count)
.ok_or_else(|| {

View File

@@ -1,40 +0,0 @@
pub mod common;
pub mod create_validators;
pub mod import_validators;
pub mod move_validators;
use crate::DumpConfig;
use clap::{App, ArgMatches};
use types::{ChainSpec, EthSpec};
pub const CMD: &str = "validators";
pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
App::new(CMD)
.about("Provides commands for managing validators in a Lighthouse Validator Client.")
.subcommand(create_validators::cli_app())
.subcommand(import_validators::cli_app())
.subcommand(move_validators::cli_app())
}
pub async fn cli_run<'a, T: EthSpec>(
matches: &'a ArgMatches<'a>,
spec: &ChainSpec,
dump_config: DumpConfig,
) -> Result<(), String> {
match matches.subcommand() {
(create_validators::CMD, Some(matches)) => {
create_validators::cli_run::<T>(matches, spec, dump_config).await
}
(import_validators::CMD, Some(matches)) => {
import_validators::cli_run(matches, dump_config).await
}
(move_validators::CMD, Some(matches)) => {
move_validators::cli_run(matches, dump_config).await
}
(unknown, _) => Err(format!(
"{} does not have a {} command. See --help",
CMD, unknown
)),
}
}