Skip to content

Commit

Permalink
consensus: add cluster votes check
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Jul 22, 2024
1 parent 1e94383 commit e47f2ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions consensus/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,17 @@ impl<V: StepVote> Aggregator<V> {
// An committee member is allowed to vote only once per a single
// step. Its vote has a weight value depending on how many times it
// has been extracted in the sortition for this step.
let weight = cluster.add(signer, weight);
debug_assert!(weight.is_some());
let added = cluster
.add(signer, weight)
.expect("Vote to be added to cluster");

let total = cluster.total_occurrences();

debug!(
event = "vote aggregated",
?vote,
from = signer.to_bs58(),
added = weight,
added,
total,
majority = committee.majority_quorum(),
super_majority = committee.super_majority_quorum(),
Expand Down
2 changes: 2 additions & 0 deletions consensus/src/user/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ where
}

/// Adds key with specified weight. Weight per key can be set only once.
///
/// Return None if `weight` is 0 or key is already set.
pub fn add(&mut self, key: &T, weight: usize) -> Option<usize> {
if weight == 0 {
return None;
Expand Down

0 comments on commit e47f2ac

Please sign in to comment.