Split out current and delinquent validators (#10702)
This commit is contained in:
@ -254,6 +254,15 @@ fn slot_to_human_time(slot: Slot) -> String {
|
|||||||
.to_string()
|
.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct CliValidatorsStakeByVersion {
|
||||||
|
pub current_validators: usize,
|
||||||
|
pub delinquent_validators: usize,
|
||||||
|
pub current_active_stake: u64,
|
||||||
|
pub delinquent_active_stake: u64,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct CliValidators {
|
pub struct CliValidators {
|
||||||
@ -262,13 +271,7 @@ pub struct CliValidators {
|
|||||||
pub total_deliquent_stake: u64,
|
pub total_deliquent_stake: u64,
|
||||||
pub current_validators: Vec<CliValidator>,
|
pub current_validators: Vec<CliValidator>,
|
||||||
pub delinquent_validators: Vec<CliValidator>,
|
pub delinquent_validators: Vec<CliValidator>,
|
||||||
pub stake_by_version: BTreeMap<
|
pub stake_by_version: BTreeMap<String, CliValidatorsStakeByVersion>,
|
||||||
String, /*version*/
|
|
||||||
(
|
|
||||||
usize, /*num validators*/
|
|
||||||
u64, /*total_active_stake*/
|
|
||||||
),
|
|
||||||
>,
|
|
||||||
#[serde(skip_serializing)]
|
#[serde(skip_serializing)]
|
||||||
pub use_lamports_unit: bool,
|
pub use_lamports_unit: bool,
|
||||||
}
|
}
|
||||||
@ -347,14 +350,23 @@ impl fmt::Display for CliValidators {
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeln!(f)?;
|
writeln!(f)?;
|
||||||
writeln!(f, "{}", style("Active Stake By Version:").bold())?;
|
writeln!(f, "{}", style("Stake By Version:").bold())?;
|
||||||
for (version, (num_validators, total_active_stake)) in self.stake_by_version.iter() {
|
for (version, info) in self.stake_by_version.iter() {
|
||||||
writeln!(
|
writeln!(
|
||||||
f,
|
f,
|
||||||
"{} x {} = {:0.2}%",
|
"{:<16} - {:3} current validators ({:>5.2}%){}",
|
||||||
version,
|
version,
|
||||||
num_validators,
|
info.current_validators,
|
||||||
100. * *total_active_stake as f64 / self.total_active_stake as f64
|
100. * info.current_active_stake as f64 / self.total_active_stake as f64,
|
||||||
|
if info.delinquent_validators > 0 {
|
||||||
|
format!(
|
||||||
|
", {:3} delinquent validators ({:>5.2}%)",
|
||||||
|
info.delinquent_validators,
|
||||||
|
100. * info.delinquent_active_stake as f64 / self.total_active_stake as f64
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
"".to_string()
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +375,7 @@ impl fmt::Display for CliValidators {
|
|||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
style(format!(
|
style(format!(
|
||||||
" {:<44} {:<38} {} {} {} {:>10} {:>17} {}",
|
" {:<44} {:<38} {} {} {} {:>10} {:^17} {}",
|
||||||
"Identity Pubkey",
|
"Identity Pubkey",
|
||||||
"Vote Account Pubkey",
|
"Vote Account Pubkey",
|
||||||
"Commission",
|
"Commission",
|
||||||
|
@ -1257,16 +1257,20 @@ pub fn process_show_validators(
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut stake_by_version: BTreeMap<_, (usize, u64)> = BTreeMap::new();
|
let mut stake_by_version: BTreeMap<_, CliValidatorsStakeByVersion> = BTreeMap::new();
|
||||||
for validator in current_validators
|
for validator in current_validators.iter() {
|
||||||
.iter()
|
|
||||||
.chain(delinquent_validators.iter())
|
|
||||||
{
|
|
||||||
let mut entry = stake_by_version
|
let mut entry = stake_by_version
|
||||||
.entry(validator.version.clone())
|
.entry(validator.version.clone())
|
||||||
.or_default();
|
.or_default();
|
||||||
entry.0 += 1;
|
entry.current_validators += 1;
|
||||||
entry.1 += validator.activated_stake;
|
entry.current_active_stake += validator.activated_stake;
|
||||||
|
}
|
||||||
|
for validator in delinquent_validators.iter() {
|
||||||
|
let mut entry = stake_by_version
|
||||||
|
.entry(validator.version.clone())
|
||||||
|
.or_default();
|
||||||
|
entry.delinquent_validators += 1;
|
||||||
|
entry.delinquent_active_stake += validator.activated_stake;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cli_validators = CliValidators {
|
let cli_validators = CliValidators {
|
||||||
|
Reference in New Issue
Block a user