Skip to content

Commit

Permalink
fix: threshold ceiling division
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaMasych committed Sep 11, 2024
1 parent 35808da commit 84d1d5c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ impl BPConConfig {
/// In the example above, the total weight is 150, and the BFT threshold is calculated as `2/3 * 150 = 100`.
pub fn compute_bft_threshold(party_weights: Vec<u64>) -> u128 {
let total_weight: u128 = party_weights.iter().map(|&w| w as u128).sum();
(2 * total_weight) / 3
(2 * total_weight + 2) / 3 // adding 2 to keep division ceiling.
}
}

0 comments on commit 84d1d5c

Please sign in to comment.