diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-05-06 12:02:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-06 12:02:43 +0800 |
commit | 42d585f1e5c9420f15b1d7333e7874a04345cc36 (patch) | |
tree | 0f4e6096fff0e7b127a807dc2673d02c21abf7f6 | |
parent | 889c61c4ea9a38f627a93f7cea617d5073a26f5f (diff) | |
download | dexon-consensus-42d585f1e5c9420f15b1d7333e7874a04345cc36.tar.gz dexon-consensus-42d585f1e5c9420f15b1d7333e7874a04345cc36.tar.zst dexon-consensus-42d585f1e5c9420f15b1d7333e7874a04345cc36.zip |
* core: fast filter already received prv share
* core: do not propose duplicated complaint
-rw-r--r-- | core/dkg-tsig-protocol.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/core/dkg-tsig-protocol.go b/core/dkg-tsig-protocol.go index d4235a4..ce5c89c 100644 --- a/core/dkg-tsig-protocol.go +++ b/core/dkg-tsig-protocol.go @@ -391,6 +391,9 @@ func (d *dkgProtocol) processNackComplaints(complaints []*typesDKG.Complaint) ( } func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) { + complained := make(map[types.NodeID]struct{}) + // Do not propose nack complaint to itself. + complained[d.ID] = struct{}{} for _, complaint := range complaints { if d.round != complaint.Round || d.reset != complaint.Reset { continue @@ -402,8 +405,7 @@ func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) { continue } to := complaint.PrivateShare.ProposerID - // Do not propose nack complaint to itself. - if to == d.ID { + if _, exist := complained[to]; exist { continue } from := complaint.ProposerID @@ -413,6 +415,7 @@ func (d *dkgProtocol) enforceNackComplaints(complaints []*typesDKG.Complaint) { } if _, exist := d.antiComplaintReceived[from][to]; !exist { + complained[to] = struct{}{} d.recv.ProposeDKGComplaint(&typesDKG.Complaint{ Round: d.round, Reset: d.reset, @@ -461,6 +464,18 @@ func (d *dkgProtocol) processPrivateShare( if !exist { return nil } + if prvShare.ReceiverID == d.ID { + if _, exist := d.prvSharesReceived[prvShare.ProposerID]; exist { + return nil + } + } else { + if _, exist := d.antiComplaintReceived[prvShare.ReceiverID]; exist { + if _, exist := + d.antiComplaintReceived[prvShare.ReceiverID][prvShare.ProposerID]; exist { + return nil + } + } + } if err := d.sanityCheck(prvShare); err != nil { return err } |