From 374554f017ea11962b29562e4333c837e6a83356 Mon Sep 17 00:00:00 2001 From: brentstone Date: Tue, 3 Sep 2024 22:23:01 -0500 Subject: [PATCH] use new `fn frac_mul_ceil` in rewards --- crates/proof_of_stake/src/rewards.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/proof_of_stake/src/rewards.rs b/crates/proof_of_stake/src/rewards.rs index 471ef02ea9f..a60b9b31dc6 100644 --- a/crates/proof_of_stake/src/rewards.rs +++ b/crates/proof_of_stake/src/rewards.rs @@ -159,14 +159,12 @@ impl PosRewardsCalculator { /// Implement as ceiling of (2/3) * validator set stake fn get_min_required_votes(&self) -> token::Amount { - (self + let min_votes = self .total_stake - .checked_mul(2_u64) - .expect("Amount overflow while computing minimum required votes") - .checked_add((3u64 - 1u64).into()) - .expect("Amount overflow while computing minimum required votes")) - .checked_div_u64(3u64) - .expect("Div by non-zero cannot fail") + .raw_amount() + .frac_mul_ceil(2.into(), 3.into()) + .expect("Amount overflow while computing minimum required votes"); + min_votes.into() } }