Skip to content

Commit

Permalink
use new fn frac_mul_ceil in rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Sep 4, 2024
1 parent 082f58c commit 374554f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions crates/proof_of_stake/src/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 374554f

Please sign in to comment.