Add wait for max stake command (#13532)
This commit is contained in:
@@ -149,6 +149,9 @@ pub enum CliCommand {
|
||||
limit: usize,
|
||||
show_transactions: bool,
|
||||
},
|
||||
WaitForMaxStake {
|
||||
max_stake_percent: f32,
|
||||
},
|
||||
// Nonce commands
|
||||
AuthorizeNonceAccount {
|
||||
nonce_account: Pubkey,
|
||||
@@ -624,6 +627,13 @@ pub fn parse_command(
|
||||
signers,
|
||||
})
|
||||
}
|
||||
("wait-for-max-stake", Some(matches)) => {
|
||||
let max_stake_percent = value_t_or_exit!(matches, "max_percent", f32);
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::WaitForMaxStake { max_stake_percent },
|
||||
signers: vec![],
|
||||
})
|
||||
}
|
||||
// Stake Commands
|
||||
("create-stake-account", Some(matches)) => {
|
||||
parse_stake_create_account(matches, default_signer, wallet_manager)
|
||||
@@ -1565,6 +1575,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||
*use_lamports_unit,
|
||||
vote_account_pubkeys.as_deref(),
|
||||
),
|
||||
CliCommand::WaitForMaxStake { max_stake_percent } => {
|
||||
process_wait_for_max_stake(&rpc_client, config, *max_stake_percent)
|
||||
}
|
||||
CliCommand::ShowValidators { use_lamports_unit } => {
|
||||
process_show_validators(&rpc_client, config, *use_lamports_unit)
|
||||
}
|
||||
|
@@ -318,6 +318,17 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
||||
.help("Display the full transactions"),
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("wait-for-max-stake")
|
||||
.about("Wait for the max stake of any one node to drop below a percentage of total.")
|
||||
.arg(
|
||||
Arg::with_name("max_percent")
|
||||
.long("max-percent")
|
||||
.value_name("PERCENT")
|
||||
.takes_value(true)
|
||||
.index(1),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,6 +1411,16 @@ pub fn process_show_stakes(
|
||||
.formatted_string(&CliStakeVec::new(stake_accounts)))
|
||||
}
|
||||
|
||||
pub fn process_wait_for_max_stake(
|
||||
rpc_client: &RpcClient,
|
||||
config: &CliConfig,
|
||||
max_stake_percent: f32,
|
||||
) -> ProcessResult {
|
||||
let now = std::time::Instant::now();
|
||||
rpc_client.wait_for_max_stake(config.commitment, max_stake_percent)?;
|
||||
Ok(format!("Done waiting, took: {}s", now.elapsed().as_secs()))
|
||||
}
|
||||
|
||||
pub fn process_show_validators(
|
||||
rpc_client: &RpcClient,
|
||||
config: &CliConfig,
|
||||
|
Reference in New Issue
Block a user