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"
|
name = "ghost-eye"
|
||||||
authors = ["str3tch <stretch@ghostchain.io>"]
|
authors = ["str3tch <stretch@ghostchain.io>"]
|
||||||
description = "Application for interacting with Casper/Ghost nodes that are exposing RPC only to the localhost"
|
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"
|
edition = "2021"
|
||||||
homepage = "https://git.ghostchain.io/ghostchain"
|
homepage = "https://git.ghostchain.io/ghostchain"
|
||||||
repository = "https://git.ghostchain.io/ghostchain/ghost-eye"
|
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 =
|
let maybe_era_reward_points =
|
||||||
super::raw_calls::staking::eras_reward_points(api, None, era_index).await?;
|
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 {
|
let (total_points, individual) = match maybe_era_reward_points {
|
||||||
Some(era_reward_points) => (
|
Some(era_reward_points) => {
|
||||||
era_reward_points.total,
|
let mut individual_era_reward_points = Vec::new();
|
||||||
era_reward_points
|
for index in 0..validators.len() {
|
||||||
.individual
|
let (account_id, points) = era_reward_points
|
||||||
.iter()
|
.individual
|
||||||
.enumerate()
|
.get(index)
|
||||||
.map(|(index, (account_id, points))| {
|
.cloned()
|
||||||
let address = AccountId32::from(account_id.0)
|
.unwrap_or((validators[index].clone(), 0));
|
||||||
.to_ss58check_with_version(Ss58AddressFormat::custom(1996));
|
|
||||||
EraRewardPoints {
|
let address = AccountId32::from(account_id.0)
|
||||||
address,
|
.to_ss58check_with_version(Ss58AddressFormat::custom(1996));
|
||||||
account_id: account_id.0,
|
|
||||||
points: *points,
|
individual_era_reward_points.push(EraRewardPoints {
|
||||||
disabled: disabled_validators.contains(&(index as u32)),
|
address,
|
||||||
}
|
points,
|
||||||
})
|
account_id: account_id.0,
|
||||||
.collect(),
|
disabled: disabled_validators.contains(&(index as u32)),
|
||||||
),
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
(era_reward_points.total, individual_era_reward_points)
|
||||||
|
},
|
||||||
None => (0, Vec::new()),
|
None => (0, Vec::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user