extract get_stake_reward fn from StakeReward (#26183)

This commit is contained in:
HaoranYi 2022-06-24 08:44:48 -05:00 committed by GitHub
parent 877fedadac
commit fbcb4d8216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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 {
@ -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();