Skip to content

Commit

Permalink
consensus: change Committee::total_occurrences to be more idiomatic
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Feb 9, 2024
1 parent 0ab78c4 commit 5eeb8e7
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions consensus/src/user/committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,10 @@ impl Committee {
}

pub fn total_occurrences(&self, voters: &Cluster<PublicKey>) -> usize {
let mut total = 0;
for (item_pk, _) in voters.iter() {
if let Some(weight) = self.votes_for(item_pk) {
total += weight;
};
}

total
voters
.iter()
.flat_map(|(voter, _)| self.votes_for(voter))
.sum()
}
}

Expand Down

0 comments on commit 5eeb8e7

Please sign in to comment.