saturating sub

This commit is contained in:
Hardhat Chad
2024-07-11 17:23:43 +00:00
parent 045f9290f3
commit 599b722130

View File

@@ -124,15 +124,13 @@ pub fn process_mine<'a, 'info>(
// Apply liveness penalty.
let t_liveness = t_target.saturating_add(TOLERANCE);
if t.gt(&t_liveness) {
reward = reward
.checked_sub(
reward
.checked_mul(t.checked_sub(t_liveness).unwrap() as u64)
.unwrap()
.checked_div(ONE_MINUTE as u64)
.unwrap(),
)
.unwrap();
reward = reward.saturating_sub(
reward
.checked_mul(t.checked_sub(t_liveness).unwrap() as u64)
.unwrap()
.checked_div(ONE_MINUTE as u64)
.unwrap(),
);
}
// Limit payout amount to whatever is left in the bus