Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor epoch reward 3 #27259

Merged
merged 9 commits into from
Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3218,19 +3218,8 @@ impl Bank {
metrics.redeem_rewards_us += m.as_us();

self.store_stake_accounts(&stake_rewards, metrics);
let mut vote_rewards = self.store_vote_accounts(vote_account_rewards, metrics);

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)));
}

let vote_rewards = self.store_vote_accounts(vote_account_rewards, metrics);
self.update_reward_history(stake_rewards, vote_rewards);
point_value.rewards as f64 / point_value.points as f64
}

Expand Down Expand Up @@ -3286,6 +3275,21 @@ impl Bank {
vote_rewards
}

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