diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-03-28 18:21:00 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-15 22:09:55 +0800 |
commit | 4efc1cf485200000420bd79638139eb5383641ae (patch) | |
tree | ae0069fd1b9ec056f1f4a39e4553bdd1f3c32c0f /dex/handler.go | |
parent | d2bfae48e7f490e803bf09579c021c7720159fc1 (diff) | |
download | go-tangerine-4efc1cf485200000420bd79638139eb5383641ae.tar.gz go-tangerine-4efc1cf485200000420bd79638139eb5383641ae.tar.zst go-tangerine-4efc1cf485200000420bd79638139eb5383641ae.zip |
dex: rebuild connection if dkg reset, core/vm: fix gov (#308)
* dex: rebuild connection if dkg reset
* core: vm: fix governance contract
Diffstat (limited to 'dex/handler.go')
-rw-r--r-- | dex/handler.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/dex/handler.go b/dex/handler.go index 8971ad500..6d0746d2f 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -1320,6 +1320,7 @@ func (pm *ProtocolManager) peerSetLoop() { pm.peers.BuildConnection(CRSRound) round = CRSRound } + resetCount := uint64(0) for { select { @@ -1334,9 +1335,12 @@ func (pm *ProtocolManager) peerSetLoop() { if newRound == 0 { break } + reset := pm.gov.DKGResetCount(round) - log.Debug("ProtocolManager: new round", "round", newRound) - if newRound <= round { + log.Debug("ProtocolManager: new round", + "round", newRound, + "reset", reset) + if newRound <= round && resetCount == reset { break } @@ -1345,6 +1349,10 @@ func (pm *ProtocolManager) peerSetLoop() { if round >= 1 { pm.peers.ForgetConnection(round - 1) } + } else if newRound == round && resetCount+1 == reset { + pm.peers.ForgetConnection(newRound) + pm.gov.PurgeNotarySet(newRound) + pm.peers.BuildConnection(newRound) } else { // just forget all network connection and rebuild. pm.peers.ForgetConnection(round) @@ -1355,6 +1363,7 @@ func (pm *ProtocolManager) peerSetLoop() { pm.peers.BuildConnection(newRound) } round = newRound + resetCount = reset case <-pm.chainHeadSub.Err(): return } |