fix era reward points getter, because it's a HashMap with possible missed validators indexes

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-12-03 22:00:29 +03:00
parent 5fcedf50dd
commit ce86092119
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
2 changed files with 27 additions and 19 deletions

View File

@ -2,7 +2,7 @@
name = "ghost-eye"
authors = ["str3tch <stretch@ghostchain.io>"]
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
version = "0.3.81"
version = "0.3.82"
edition = "2021"
homepage = "https://git.ghostchain.io/ghostchain"
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"

View File

@ -352,25 +352,33 @@ pub async fn get_current_validator_reward_in_era(
let maybe_era_reward_points =
super::raw_calls::staking::eras_reward_points(api, None, era_index).await?;
let validators = super::raw_calls::session::validators(api, None)
.await?
.unwrap_or_default();
let (total_points, individual) = match maybe_era_reward_points {
Some(era_reward_points) => (
era_reward_points.total,
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
.iter()
.enumerate()
.map(|(index, (account_id, points))| {
.get(index)
.cloned()
.unwrap_or((validators[index].clone(), 0));
let address = AccountId32::from(account_id.0)
.to_ss58check_with_version(Ss58AddressFormat::custom(1996));
EraRewardPoints {
individual_era_reward_points.push(EraRewardPoints {
address,
points,
account_id: account_id.0,
points: *points,
disabled: disabled_validators.contains(&(index as u32)),
});
}
})
.collect(),
),
(era_reward_points.total, individual_era_reward_points)
},
None => (0, Vec::new()),
};