From 10b9225edb67ce3287cd0c6e85dca083d0f0a69e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2020 18:12:14 +0000 Subject: [PATCH] Don't bother paying 0 rent (#12793) (cherry picked from commit 1fc7c1eceee8127ab4a0445db0f938f3eb3d87ae) Co-authored-by: Michael Vines --- runtime/src/bank.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 0f11d8e8fd..7b893b08e4 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -2676,17 +2676,19 @@ impl Bank { } else { rent_share }; - let mut account = self.get_account(&pubkey).unwrap_or_default(); - account.lamports += rent_to_be_paid; - self.store_account(&pubkey, &account); - rewards.push(( - pubkey, - RewardInfo { - reward_type: RewardType::Rent, - lamports: rent_to_be_paid as i64, - post_balance: account.lamports, - }, - )); + if rent_to_be_paid > 0 { + let mut account = self.get_account(&pubkey).unwrap_or_default(); + account.lamports += rent_to_be_paid; + self.store_account(&pubkey, &account); + rewards.push(( + pubkey, + RewardInfo { + reward_type: RewardType::Rent, + lamports: rent_to_be_paid as i64, + post_balance: account.lamports, + }, + )); + } }); self.rewards.write().unwrap().append(&mut rewards);