Skip to content

Commit

Permalink
Simplify entry insertion/update
Browse files Browse the repository at this point in the history
  • Loading branch information
moshababo committed Dec 19, 2023
1 parent a274fc5 commit 4526f51
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions node/libs/roles/src/validator/messages/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,20 +198,11 @@ impl PrepareQC {
signed_message: &Signed<ReplicaPrepare>,
validator_index: (usize, usize),
) {
// TODO: refactor to cleaner code
if self.map.contains_key(&signed_message.msg) {
self.map
.get_mut(&signed_message.msg)
.unwrap()
.0
.set(validator_index.0, true);
} else {
let mut bit_vec = BitVec::from_elem(validator_index.1, false);
bit_vec.set(validator_index.0, true);

self.map
.insert(signed_message.msg.clone(), Signers(bit_vec));
}
self.map
.entry(signed_message.msg.clone())
.or_insert_with(|| Signers(BitVec::from_elem(validator_index.1, false)))
.0
.set(validator_index.0, true);

self.signature.add(&signed_message.sig);
}
Expand Down

0 comments on commit 4526f51

Please sign in to comment.