aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/dexon-foundation/dexon-consensus/core/utils
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-08 15:32:32 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec (patch)
treea3a7ce90940fdf7e0eeb2003e9b078da50fc7904 /vendor/github.com/dexon-foundation/dexon-consensus/core/utils
parent586574e39d8e7a057f0092bdb8374a130384a531 (diff)
downloadgo-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar.gz
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar.bz2
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar.lz
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar.xz
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.tar.zst
go-tangerine-1a2059fc4e00a34fb555dff1528d6a1e88e7a1ec.zip
vendor: sync to latest core
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/utils')
-rw-r--r--vendor/github.com/dexon-foundation/dexon-consensus/core/utils/vote-filter.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/vote-filter.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/vote-filter.go
index a19902758..2fc18bb34 100644
--- a/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/vote-filter.go
+++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/utils/vote-filter.go
@@ -24,6 +24,7 @@ import (
// VoteFilter filters votes that are useless for now.
// To maximize performance, this structure is not thread-safe and will never be.
type VoteFilter struct {
+ Voted map[types.VoteHeader]struct{}
Height uint64
LockIter uint64
Period uint64
@@ -32,7 +33,9 @@ type VoteFilter struct {
// NewVoteFilter creates a new vote filter instance.
func NewVoteFilter() *VoteFilter {
- return &VoteFilter{}
+ return &VoteFilter{
+ Voted: make(map[types.VoteHeader]struct{}),
+ }
}
// Filter checks if the vote should be filtered out.
@@ -57,5 +60,13 @@ func (vf *VoteFilter) Filter(vote *types.Vote) bool {
vote.BlockHash == types.SkipBlockHash {
return true
}
+ if _, exist := vf.Voted[vote.VoteHeader]; exist {
+ return true
+ }
return false
}
+
+// AddVote to the filter so the same vote will be filtered.
+func (vf *VoteFilter) AddVote(vote *types.Vote) {
+ vf.Voted[vote.VoteHeader] = struct{}{}
+}