Skip to content

Commit ba45cc5

Browse files
committed
Add delete all validators
1 parent 8556f85 commit ba45cc5

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

validator_manager/src/delete_validators.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ pub fn cli_app() -> Command {
4545
Arg::new(VALIDATOR_FLAG)
4646
.long(VALIDATOR_FLAG)
4747
.value_name("STRING")
48-
.help("Comma-separated list of validators (pubkey) that will be deleted.")
48+
.help(
49+
"Comma-separated list of validators (pubkey) that will be deleted. \
50+
To delete all validators, use the keyword \"all\".",
51+
)
4952
.action(ArgAction::Set)
5053
.required(true)
5154
.display_order(0),
@@ -64,10 +67,14 @@ impl DeleteConfig {
6467
let validators_to_delete_str =
6568
clap_utils::parse_required::<String>(matches, VALIDATOR_FLAG)?;
6669

67-
let validators_to_delete = validators_to_delete_str
68-
.split(',')
69-
.map(|s| s.trim().parse())
70-
.collect::<Result<Vec<PublicKeyBytes>, _>>()?;
70+
let validators_to_delete = if validators_to_delete_str.trim() == "all" {
71+
Vec::new()
72+
} else {
73+
validators_to_delete_str
74+
.split(',')
75+
.map(|s| s.trim().parse())
76+
.collect::<Result<Vec<PublicKeyBytes>, _>>()?
77+
};
7178

7279
Ok(Self {
7380
vc_token_path: clap_utils::parse_required(matches, VC_TOKEN_FLAG)?,
@@ -90,11 +97,16 @@ async fn run<'a>(config: DeleteConfig) -> Result<(), String> {
9097
let DeleteConfig {
9198
vc_url,
9299
vc_token_path,
93-
validators_to_delete,
100+
mut validators_to_delete,
94101
} = config;
95102

96103
let (http_client, validators) = vc_http_client(vc_url.clone(), &vc_token_path).await?;
97104

105+
// Delete all validators on the VC
106+
if validators_to_delete.is_empty() {
107+
validators_to_delete = validators.iter().map(|v| v.validating_pubkey).collect();
108+
}
109+
98110
for validator_to_delete in &validators_to_delete {
99111
if !validators
100112
.iter()

validator_manager/src/exit_validators.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ pub fn cli_app() -> Command {
5353
Arg::new(VALIDATOR_FLAG)
5454
.long(VALIDATOR_FLAG)
5555
.value_name("STRING")
56-
.help("List of validators (pubkey) to exit.")
56+
.help(
57+
"Comma-separated list of validators (pubkey) to exit. \
58+
To exit all validators, use the keyword \"all\".",
59+
)
5760
.action(ArgAction::Set)
5861
.required(true)
5962
.display_order(0),

0 commit comments

Comments
 (0)