aboutsummaryrefslogtreecommitdiffstats
path: root/core/dkg-tsig-protocol.go
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-12-14 20:56:24 +0800
committerGitHub <noreply@github.com>2018-12-14 20:56:24 +0800
commit5f32dc8d27564e1f3a105fd1dacf02130b08621a (patch)
treed2649afe0df27de2ec2eb84f4709a2c7699d3d22 /core/dkg-tsig-protocol.go
parent155e31175aeaa3685c57383e386c6e62c46318ef (diff)
downloaddexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar.gz
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar.bz2
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar.lz
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar.xz
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.tar.zst
dexon-consensus-5f32dc8d27564e1f3a105fd1dacf02130b08621a.zip
core: Fix a bug of DKGNackComplaints (#370)
* core: Fix a bug if DKGNackComplaint is added after required time. * Duplicated NackComplaint should be only count once.
Diffstat (limited to 'core/dkg-tsig-protocol.go')
-rw-r--r--core/dkg-tsig-protocol.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go
index 6645ecb..8e03cbb 100644
--- a/core/dkg-tsig-protocol.go
+++ b/core/dkg-tsig-protocol.go
@@ -378,16 +378,21 @@ func NewDKGGroupPublicKey(
// Calculate qualify members.
disqualifyIDs := map[types.NodeID]struct{}{}
- complaintsByID := map[types.NodeID]int{}
+ complaintsByID := map[types.NodeID]map[types.NodeID]struct{}{}
for _, complaint := range complaints {
if complaint.IsNack() {
- complaintsByID[complaint.PrivateShare.ProposerID]++
+ if _, exist := complaintsByID[complaint.PrivateShare.ProposerID]; !exist {
+ complaintsByID[complaint.PrivateShare.ProposerID] =
+ make(map[types.NodeID]struct{})
+ }
+ complaintsByID[complaint.PrivateShare.ProposerID][complaint.ProposerID] =
+ struct{}{}
} else {
disqualifyIDs[complaint.PrivateShare.ProposerID] = struct{}{}
}
}
- for nID, num := range complaintsByID {
- if num > threshold {
+ for nID, complaints := range complaintsByID {
+ if len(complaints) > threshold {
disqualifyIDs[nID] = struct{}{}
}
}