Skip to content

Commit

Permalink
Refactor epoch reward 3 (#27259)
Browse files Browse the repository at this point in the history
* refactor: extract store_stake_accounts fn

* refactor: extract store_vote_account fn

* refactor: extract reward history update fn

* clippy: slice

* clippy: slice

Co-authored-by: haoran <haoran@mbook>
  • Loading branch information
HaoranYi and haoran committed Aug 21, 2022
1 parent bdf3735 commit bac5297
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3295,6 +3295,21 @@ impl Bank {
>>>>>>> c17f15a34f (Refactor epoch reward 2 (#27257))
}

fn update_reward_history(
&self,
stake_rewards: Vec<StakeReward>,
mut vote_rewards: Vec<(Pubkey, RewardInfo)>,
) {
let additional_reserve = stake_rewards.len() + vote_rewards.len();
let mut rewards = self.rewards.write().unwrap();
rewards.reserve(additional_reserve);
rewards.append(&mut vote_rewards);
stake_rewards
.into_iter()
.filter(|x| x.get_stake_reward() > 0)
.for_each(|x| rewards.push((x.stake_pubkey, x.stake_reward_info)));
}

fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) {
#[allow(deprecated)]
self.update_sysvar_account(&sysvar::recent_blockhashes::id(), |account| {
Expand Down

0 comments on commit bac5297

Please sign in to comment.