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:
parent
5fcedf50dd
commit
ce86092119
@ -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"
|
||||
|
||||
@ -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
|
||||
.individual
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, (account_id, points))| {
|
||||
let address = AccountId32::from(account_id.0)
|
||||
.to_ss58check_with_version(Ss58AddressFormat::custom(1996));
|
||||
EraRewardPoints {
|
||||
address,
|
||||
account_id: account_id.0,
|
||||
points: *points,
|
||||
disabled: disabled_validators.contains(&(index as u32)),
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
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 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)),
|
||||
});
|
||||
}
|
||||
|
||||
(era_reward_points.total, individual_era_reward_points)
|
||||
},
|
||||
None => (0, Vec::new()),
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user