aboutsummaryrefslogtreecommitdiffstats
path: root/dex/handler.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@byzantine-lab.io>2019-07-25 15:40:17 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-09-17 16:57:31 +0800
commita9a85fa746c727063015d6e70881426ce8b3a3fb (patch)
treec64c47914fe2b0b5af2f9b3c5141bbf0c26a4331 /dex/handler.go
parent38ba6a197f6f16e59b27db97e503a782d385a7c8 (diff)
downloadgo-tangerine-a9a85fa746c727063015d6e70881426ce8b3a3fb.tar.gz
go-tangerine-a9a85fa746c727063015d6e70881426ce8b3a3fb.tar.zst
go-tangerine-a9a85fa746c727063015d6e70881426ce8b3a3fb.zip
dex: minor refactor
Diffstat (limited to 'dex/handler.go')
-rw-r--r--dex/handler.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/dex/handler.go b/dex/handler.go
index 9ad35ed30..ca26bc6e8 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -1288,10 +1288,9 @@ func (pm *ProtocolManager) SetReceiveCoreMessage(enabled bool) {
// TODO: finish this
func (pm *ProtocolManager) peerSetLoop() {
round := pm.gov.Round()
- resetCount := pm.gov.DKGResetCount(round)
+ reset := pm.gov.DKGResetCount(round)
log.Debug("ProtocolManager: startup round",
- "round", round,
- "reset", resetCount)
+ "round", round, "reset", reset)
if round < dexCore.DKGDelayRound {
for i := round; i <= dexCore.DKGDelayRound; i++ {
@@ -1305,7 +1304,7 @@ func (pm *ProtocolManager) peerSetLoop() {
if CRSRound > round {
pm.peers.BuildConnection(CRSRound)
round = CRSRound
- resetCount = pm.gov.DKGResetCount(round)
+ reset = pm.gov.DKGResetCount(round)
}
ctx, cancel := context.WithCancel(context.Background())
@@ -1334,22 +1333,22 @@ func (pm *ProtocolManager) peerSetLoop() {
if newRound == 0 {
break
}
- reset := pm.gov.DKGResetCount(round)
+ newReset := pm.gov.DKGResetCount(round)
- log.Debug("ProtocolManager: new round",
- "round", newRound,
- "reset", reset)
- if newRound <= round && resetCount == reset {
+ if newRound <= round && reset == newReset {
break
}
+ log.Info("ProtocolManager: configuration changed",
+ "round", newRound, "reset", newReset)
+
if newRound == round+1 {
pm.peers.BuildConnection(newRound)
if round >= 1 {
pm.peers.ForgetConnection(round - 1)
}
- } else if newRound == round && resetCount+1 == reset {
- pm.peers.ForgetLabelConnection(peerLabel{set: notaryset, round: newRound})
+ } else if newRound == round && reset+1 == newReset {
+ pm.peers.ForgetLabelConnection(peerLabel{set: notaryset, round: round})
pm.gov.PurgeNotarySet(newRound)
pm.peers.BuildConnection(newRound)
} else {
@@ -1361,8 +1360,9 @@ func (pm *ProtocolManager) peerSetLoop() {
}
pm.peers.BuildConnection(newRound)
}
+
round = newRound
- resetCount = reset
+ reset = newReset
case <-pm.chainHeadSub.Err():
return
}