File tree 2 files changed +11
-3
lines changed
core-consensus/src/handle
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change 77
77
78
78
debug_assert_eq ! ( consensus_height, vote_height) ;
79
79
80
- // Only append to WAL and store precommits if we're in the validator set
81
- if state. is_validator ( ) {
80
+ // Only append to WAL and store precommits if we're in the validator set,
81
+ // and we have not yet seen this vote.
82
+ if state. is_validator ( ) && !state. driver . votes ( ) . has_vote ( & signed_vote) {
82
83
// Append the vote to the Write-ahead Log
83
84
perform ! (
84
85
co,
Original file line number Diff line number Diff line change 96
96
}
97
97
}
98
98
99
- // Add the vote to the round
99
+ // Tally this vote
100
100
self . votes . add_vote ( & vote, weight) ;
101
101
102
102
// Update the weight of the validator
@@ -205,6 +205,13 @@ where
205
205
& self . evidence
206
206
}
207
207
208
+ /// Check if we have already seen a vote.
209
+ pub fn has_vote ( & self , vote : & SignedVote < Ctx > ) -> bool {
210
+ self . per_round
211
+ . get ( & vote. round ( ) )
212
+ . is_some_and ( |per_round| per_round. received_votes ( ) . contains ( vote) )
213
+ }
214
+
208
215
/// Apply a vote with a given weight, potentially triggering an output.
209
216
pub fn apply_vote (
210
217
& mut self ,
You can’t perform that action at this time.
0 commit comments