Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
extract get_stake_reward fn from StakeReward (#26183)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi authored Jun 24, 2022
1 parent 877feda commit fbcb4d8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,12 @@ struct StakeReward {
stake_account: AccountSharedData,
}

impl StakeReward {
pub fn get_stake_reward(&self) -> i64 {
self.stake_reward_info.lamports
}
}

/// allow [StakeReward] to be passed to `StoreAccounts` directly without copies or vec construction
impl<'a> StorableAccounts<'a, AccountSharedData> for (Slot, &'a [StakeReward]) {
fn pubkey(&self, index: usize) -> &Pubkey {
Expand Down Expand Up @@ -3204,7 +3210,7 @@ impl Bank {

let mut stake_rewards = stake_rewards
.into_iter()
.filter(|x| x.stake_reward_info.lamports > 0)
.filter(|x| x.get_stake_reward() > 0)
.map(|x| (x.stake_pubkey, x.stake_reward_info))
.collect();

Expand Down

0 comments on commit fbcb4d8

Please sign in to comment.