aboutsummaryrefslogtreecommitdiffstats
path: root/consensus/clique/snapshot.go
diff options
context:
space:
mode:
Diffstat (limited to 'consensus/clique/snapshot.go')
-rw-r--r--consensus/clique/snapshot.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go
index 8eaf3b62e..32a1191db 100644
--- a/consensus/clique/snapshot.go
+++ b/consensus/clique/snapshot.go
@@ -126,11 +126,17 @@ func (s *Snapshot) copy() *Snapshot {
return cpy
}
+// validVote returns whether it makes sense to cast the specified vote in the
+// given snapshot context (e.g. don't try to add an already authorized signer).
+func (s *Snapshot) validVote(address common.Address, authorize bool) bool {
+ _, signer := s.Signers[address]
+ return (signer && !authorize) || (!signer && authorize)
+}
+
// cast adds a new vote into the tally.
func (s *Snapshot) cast(address common.Address, authorize bool) bool {
// Ensure the vote is meaningful
- _, signer := s.Signers[address]
- if (signer && authorize) || (!signer && !authorize) {
+ if !s.validVote(address, authorize) {
return false
}
// Cast the vote into an existing or new tally