From 6786ac62add22e773b5e192e13adfd5ef720869b Mon Sep 17 00:00:00 2001 From: Jimmy Hu Date: Fri, 29 Mar 2019 14:28:17 +0800 Subject: core: fix forget connection in resetDKG (#314) --- dex/handler.go | 2 +- dex/peer.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/dex/handler.go b/dex/handler.go index 161f4a4d8..6395c4113 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -1351,7 +1351,7 @@ func (pm *ProtocolManager) peerSetLoop() { pm.peers.ForgetConnection(round - 1) } } else if newRound == round && resetCount+1 == reset { - pm.peers.ForgetConnection(newRound) + pm.peers.ForgetLabelConnection(peerLabel{set: notaryset, round: newRound}) pm.gov.PurgeNotarySet(newRound) pm.peers.BuildConnection(newRound) } else { diff --git a/dex/peer.go b/dex/peer.go index d3650d00d..d0e717233 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -922,7 +922,18 @@ func (ps *peerSet) BuildConnection(round uint64) { ps.buildGroupConn(notaryLabel) } } +} + +func (ps *peerSet) ForgetLabelConnection(label peerLabel) { + ps.lock.Lock() + defer ps.lock.Unlock() + log.Debug("Forget label connection", "label", label) + ps.forgetDirectConn(label) + ps.forgetGroupConn(label) + delete(ps.directConn, label) + delete(ps.groupConnPeers, label) + delete(ps.label2Nodes, label) } func (ps *peerSet) ForgetConnection(round uint64) { -- cgit v1.2.3