aboutsummaryrefslogtreecommitdiffstats
path: root/dex/handler.go
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2019-02-25 19:35:06 +0800
committerWei-Ning Huang <w@dexon.org>2019-03-12 12:19:09 +0800
commit4ce8adb190ae3351a507be54f38afa6b47ce18a3 (patch)
tree585b6f4bb5ee06b0fdab0f8e68f34e15b6ae0fed /dex/handler.go
parent0ac79d780ba63c574d648552f887c9411fdd76fe (diff)
downloaddexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.gz
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.bz2
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.lz
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.xz
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.tar.zst
dexon-4ce8adb190ae3351a507be54f38afa6b47ce18a3.zip
core: vm: flatten governance
Diffstat (limited to 'dex/handler.go')
-rw-r--r--dex/handler.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/dex/handler.go b/dex/handler.go
index 4ffa01244..5bd615c86 100644
--- a/dex/handler.go
+++ b/dex/handler.go
@@ -45,6 +45,7 @@ import (
"time"
coreCommon "github.com/dexon-foundation/dexon-consensus/common"
+ dexCore "github.com/dexon-foundation/dexon-consensus/core"
coreCrypto "github.com/dexon-foundation/dexon-consensus/core/crypto"
coreTypes "github.com/dexon-foundation/dexon-consensus/core/types"
dkgTypes "github.com/dexon-foundation/dexon-consensus/core/types/dkg"
@@ -1199,13 +1200,18 @@ func (pm *ProtocolManager) recordBroadcastLoop() {
// a loop keep building and maintaining peers in notary set.
// TODO: finish this
func (pm *ProtocolManager) peerSetLoop() {
- log.Debug("start peer set loop")
- round := pm.gov.LenCRS() - 1
- log.Trace("first len crs", "len", round+1, "round", round)
- if round >= 1 {
- pm.peers.BuildConnection(round - 1)
+ log.Debug("ProtocolManager: started peer set loop")
+
+ round := pm.gov.Round()
+ log.Trace("ProtocolManager: startup round", "round", round)
+
+ if round < dexCore.DKGDelayRound {
+ for i := round; i <= dexCore.DKGDelayRound; i++ {
+ pm.peers.BuildConnection(i)
+ }
+ } else {
+ pm.peers.BuildConnection(round)
}
- pm.peers.BuildConnection(round)
for {
select {
@@ -1216,11 +1222,16 @@ func (pm *ProtocolManager) peerSetLoop() {
break
}
- newRound := pm.gov.LenCRS() - 1
- log.Trace("new round", "round", newRound)
+ newRound := pm.gov.CRSRound()
+ if newRound == 0 {
+ break
+ }
+
+ log.Debug("ProtocolManager: new round", "round", newRound)
if newRound == round {
break
}
+
if newRound == round+1 {
pm.peers.BuildConnection(newRound)
if round >= 1 {