Add --minimum-validator-identity-balance
This commit is contained in:
parent
391a1ea760
commit
a12ede8e7d
|
@ -5,7 +5,7 @@ use {
|
|||
log::*,
|
||||
solana_clap_utils::{
|
||||
input_parsers::pubkeys_of,
|
||||
input_validators::{is_pubkey_or_keypair, is_url},
|
||||
input_validators::{is_parsable, is_pubkey_or_keypair, is_url},
|
||||
},
|
||||
solana_cli_output::display::format_labeled_address,
|
||||
solana_client::{client_error, rpc_client::RpcClient, rpc_response::RpcVoteAccountStatus},
|
||||
|
@ -29,6 +29,7 @@ struct Config {
|
|||
ignore_http_bad_gateway: bool,
|
||||
interval: Duration,
|
||||
json_rpc_url: String,
|
||||
minimum_validator_identity_balance: u64,
|
||||
monitor_active_stake: bool,
|
||||
unhealthy_threshold: usize,
|
||||
validator_identity_pubkeys: Vec<Pubkey>,
|
||||
|
@ -102,6 +103,15 @@ fn get_config() -> Config {
|
|||
.multiple(true)
|
||||
.help("Validator identities to monitor for delinquency")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("minimum_validator_identity_balance")
|
||||
.long("minimum-validator-identity-balance")
|
||||
.value_name("SOL")
|
||||
.takes_value(true)
|
||||
.default_value("10")
|
||||
.validator(is_parsable::<f64>)
|
||||
.help("Alert when the validator identity balance is less than this amount of SOL")
|
||||
)
|
||||
.arg(
|
||||
// Deprecated parameter, now always enabled
|
||||
Arg::with_name("no_duplicate_notifications")
|
||||
|
@ -133,6 +143,11 @@ fn get_config() -> Config {
|
|||
|
||||
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
|
||||
let unhealthy_threshold = value_t_or_exit!(matches, "unhealthy_threshold", usize);
|
||||
let minimum_validator_identity_balance = sol_to_lamports(value_t_or_exit!(
|
||||
matches,
|
||||
"minimum_validator_identity_balance",
|
||||
f64
|
||||
));
|
||||
let json_rpc_url =
|
||||
value_t!(matches, "json_rpc_url", String).unwrap_or_else(|_| config.json_rpc_url.clone());
|
||||
let validator_identity_pubkeys: Vec<_> = pubkeys_of(&matches, "validator_identities")
|
||||
|
@ -148,6 +163,7 @@ fn get_config() -> Config {
|
|||
ignore_http_bad_gateway,
|
||||
interval,
|
||||
json_rpc_url,
|
||||
minimum_validator_identity_balance,
|
||||
monitor_active_stake,
|
||||
unhealthy_threshold,
|
||||
validator_identity_pubkeys,
|
||||
|
@ -283,9 +299,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
|
|||
}
|
||||
|
||||
if let Some(balance) = validator_balances.get(&validator_identity) {
|
||||
if *balance < sol_to_lamports(10.) {
|
||||
// At 1 SOL/day for validator voting fees, this gives over a week to
|
||||
// find some more SOL
|
||||
if *balance < config.minimum_validator_identity_balance {
|
||||
failures.push((
|
||||
"balance",
|
||||
format!("{} has {}", formatted_validator_identity, Sol(*balance)),
|
||||
|
|
Loading…
Reference in New Issue