correct reverse indexing in BTreeMap
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
3284d5d07e
commit
3557e5fa4e
@ -64,19 +64,18 @@ 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)
|
||||
.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));
|
||||
let rev_index = self.rewards.len()
|
||||
.saturating_sub(index)
|
||||
.saturating_sub(1);
|
||||
|
||||
if let Some(era_index) = self.rewards.keys().nth(rev_index) {
|
||||
let is_claimed = self.rewards
|
||||
.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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user