From 01304b91c56c60e6855ec8cb7e1c4ef5ab3a7657 Mon Sep 17 00:00:00 2001 From: haoran Date: Fri, 19 Aug 2022 10:39:15 -0500 Subject: [PATCH 1/2] refactor: extract store_stake_accounts fn --- runtime/src/bank.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 32ece32f8892d1..6d8ab2443b4166 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3182,14 +3182,7 @@ impl Bank { m.stop(); metrics.redeem_rewards_us += m.as_us(); - // store stake account even if stakers_reward is 0 - // because credits observed has changed - let mut m = Measure::start("store_stake_account"); - self.store_accounts((self.slot(), &stake_rewards[..])); - m.stop(); - metrics - .store_stake_accounts_us - .fetch_add(m.as_us(), Relaxed); + self.store_stake_accounts(&stake_rewards, metrics); let mut m = Measure::start("store_vote_accounts"); let mut vote_rewards = vote_account_rewards @@ -3239,6 +3232,17 @@ impl Bank { point_value.rewards as f64 / point_value.points as f64 } + fn store_stake_accounts(&self, stake_rewards: &Vec, metrics: &mut RewardsMetrics) { + // store stake account even if stakers_reward is 0 + // because credits observed has changed + let mut m = Measure::start("store_stake_account"); + self.store_accounts((self.slot(), &stake_rewards[..])); + m.stop(); + metrics + .store_stake_accounts_us + .fetch_add(m.as_us(), Relaxed); + } + fn update_recent_blockhashes_locked(&self, locked_blockhash_queue: &BlockhashQueue) { #[allow(deprecated)] self.update_sysvar_account(&sysvar::recent_blockhashes::id(), |account| { From 4cbf6439d8ff9f9838afc9bed28a055b451e5ebc Mon Sep 17 00:00:00 2001 From: haoran Date: Fri, 19 Aug 2022 11:35:15 -0500 Subject: [PATCH 2/2] clippy: slice --- runtime/src/bank.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 6d8ab2443b4166..56e67e0848804b 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3232,11 +3232,11 @@ impl Bank { point_value.rewards as f64 / point_value.points as f64 } - fn store_stake_accounts(&self, stake_rewards: &Vec, metrics: &mut RewardsMetrics) { + fn store_stake_accounts(&self, stake_rewards: &[StakeReward], metrics: &mut RewardsMetrics) { // store stake account even if stakers_reward is 0 // because credits observed has changed let mut m = Measure::start("store_stake_account"); - self.store_accounts((self.slot(), &stake_rewards[..])); + self.store_accounts((self.slot(), stake_rewards)); m.stop(); metrics .store_stake_accounts_us