correct history depth for historical payout rewards

Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
Uncle Stretch 2025-02-17 14:12:31 +03:00
parent 76d87aecbf
commit 309c97d60e
Signed by: str3tch
GPG Key ID: 84F3190747EE79AA
4 changed files with 17 additions and 17 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.28"
version = "0.3.29"
edition = "2021"
[dependencies]

View File

@ -64,17 +64,19 @@ impl History {
fn payout_by_era_index(&mut self) {
if let Some(index) = self.table_state.selected() {
let length = self.rewards.len() as u32;
let era_index = self.rewards
.keys()
.nth(index)
.map(|i| length - i - 1)
.expect("BTreeMap of rewards is indexed; qed");
let is_claimed = self.rewards
.get(era_index)
.get(&era_index)
.map(|x| x.is_claimed)
.expect("BTreeMap of rewards is indexed; qed");
if let Some(action_tx) = &self.action_tx {
let _ = action_tx.send(
Action::PayoutValidatorPopup(*era_index, is_claimed));
Action::PayoutValidatorPopup(era_index, is_claimed));
}
}
}
@ -242,6 +244,7 @@ impl Component for History {
let table = Table::new(
self.rewards
.iter()
.rev()
.map(|(key, value)| {
let mut era_index_text = Text::from(key.to_string()).alignment(Alignment::Left);
let mut slash_text = Text::from(self.prepare_u128(value.slash)).alignment(Alignment::Center);

View File

@ -281,20 +281,9 @@ pub async fn get_validator_staking_results(
api: &OnlineClient<CasperConfig>,
account_id: &[u8; 32],
) -> Result<()> {
let (start, end) = super::raw_calls::historical::stored_range(api, None)
.await?
.map(|range| {
(
range.0
.saturating_div(6)
.saturating_sub(1),
range.1
.saturating_div(6)
.saturating_sub(1),
)
})
.unwrap_or((0, 0));
for era_index in start..end {
let current_era = super::raw_calls::staking::current_era(api, None).await?.unwrap_or(0);
let era_depth = super::raw_calls::staking::history_depth(api).unwrap_or(0);
for era_index in current_era.saturating_sub(era_depth)..current_era {
get_validator_staking_result(action_tx, api, account_id, era_index).await?;
}
Ok(())

View File

@ -194,3 +194,11 @@ pub async fn slashing_spans(
let maybe_slashing_spans = super::do_storage_call(online_client, &storage_key, at_hash).await?;
Ok(maybe_slashing_spans)
}
pub fn history_depth(
online_client: &OnlineClient<CasperConfig>,
) -> Result<u32> {
let constant_query = casper_network::constants().staking().history_depth();
let history_depth = super::do_constant_call(online_client, &constant_query)?;
Ok(history_depth)
}