From ffb2f3787ec5cee6e0e1acddbdc863e9156f6209 Mon Sep 17 00:00:00 2001 From: Uncle Stretch Date: Sat, 6 Dec 2025 13:33:28 +0300 Subject: [PATCH] fix for disabled validator index Signed-off-by: Uncle Stretch --- Cargo.toml | 2 +- src/components/health.rs | 4 ++-- src/network/predefined_calls.rs | 38 ++++++++++++++++++--------------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebbe274..bfc73f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ghost-eye" authors = ["str3tch "] description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost" -version = "0.3.82" +version = "0.3.83" edition = "2021" homepage = "https://git.ghostchain.io/ghostchain" repository = "https://git.ghostchain.io/ghostchain/ghost-eye" diff --git a/src/components/health.rs b/src/components/health.rs index c9a3960..f5fde87 100644 --- a/src/components/health.rs +++ b/src/components/health.rs @@ -91,8 +91,8 @@ impl Component for Health { self.tx_pool_length, self.peers_as_string(), self.is_syncing_as_string(), - self.validators_count, - self.nominators_count); + self.validators_count + 1, + self.nominators_count + 1); let span = Span::styled(message, Style::new().dim()); let paragraph = Paragraph::new(span).left_aligned(); diff --git a/src/network/predefined_calls.rs b/src/network/predefined_calls.rs index 4f5e3c9..9ad2989 100644 --- a/src/network/predefined_calls.rs +++ b/src/network/predefined_calls.rs @@ -1,3 +1,5 @@ +use std::collections::BTreeMap; + use color_eyre::Result; use subxt::{ backend::rpc::RpcClient, @@ -358,26 +360,28 @@ pub async fn get_current_validator_reward_in_era( let (total_points, individual) = match maybe_era_reward_points { Some(era_reward_points) => { - let mut individual_era_reward_points = Vec::new(); - for index in 0..validators.len() { - let (account_id, points) = era_reward_points - .individual - .get(index) - .cloned() - .unwrap_or((validators[index].clone(), 0)); + let points_map: BTreeMap<[u8; 32], u32> = era_reward_points.individual + .iter() + .map(|reward_info| (reward_info.0.0, reward_info.1)) + .collect(); - let address = AccountId32::from(account_id.0) - .to_ss58check_with_version(Ss58AddressFormat::custom(1996)); + let extended_era_reward_points = validators.into_iter() + .enumerate() + .map(|(index, account_id)| { + let points = points_map.get(&account_id.0).copied().unwrap_or_default(); + let address = AccountId32::from(account_id.0) + .to_ss58check_with_version(Ss58AddressFormat::custom(1996)); - individual_era_reward_points.push(EraRewardPoints { - address, - points, - account_id: account_id.0, - disabled: disabled_validators.contains(&(index as u32)), - }); - } + EraRewardPoints { + address, + points, + account_id: account_id.0, + disabled: disabled_validators.contains(&(index as u32)), + } + }) + .collect(); - (era_reward_points.total, individual_era_reward_points) + (era_reward_points.total, extended_era_reward_points) }, None => (0, Vec::new()), };