Skip to content

Commit

Permalink
improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ank4n committed Aug 29, 2023
1 parent 5a3ee5d commit 289d80b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions substrate/frame/nomination-pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,17 +1300,19 @@ impl<T: Config> RewardPool<T> {
self.total_commission_pending =
self.total_commission_pending.saturating_add(new_pending_commission);

// Store the total payouts at the time of this update. Total payouts are essentially the
// entire historical balance of the reward pool, equating to the current balance + the total
// rewards that have left the pool + the total commission that has left the pool.
// Total payouts are essentially the entire historical balance of the reward pool, equating
// to the current balance + the total rewards that have left the pool + the total commission
// that has left the pool.
let last_recorded_total_payouts = balance
.checked_add(&self.total_rewards_claimed.saturating_add(self.total_commission_claimed))
.ok_or(Error::<T>::OverflowRisk)?;

// Store the total payouts at the time of this update.
//
// An increase in ED could cause `last_recorded_total_payouts` to decrease but we should not
// allow that to happen since an already paid out reward cannot decrease. The reward account
// might go in deficit temporarily if this happens but it will be corrected once new rewards
// are added to the pool.
// might go in deficit temporarily in this exceptional case but it will be corrected once
// new rewards are added to the pool.
self.last_recorded_total_payouts =
self.last_recorded_total_payouts.max(last_recorded_total_payouts);

Expand Down

0 comments on commit 289d80b

Please sign in to comment.