From 84d1d5c96af43487b8204589ff773d40c260f5fc Mon Sep 17 00:00:00 2001 From: Nikita Masych Date: Wed, 11 Sep 2024 03:51:09 +0300 Subject: [PATCH] fix: threshold ceiling division --- src/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 2c4e2a0..572f8bb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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) -> 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. } }