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-04-09 21:32:57 +0800
commitb708ec0f082d431dfe6d56882d58043811647ac7 (patch)
tree575195174be8546146d64b79760288b5f5a8e7b4 /dex/handler.go
parente83bcc1097d49b46b79131e546f1270b9192cc05 (diff)
downloaddexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.gz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.bz2
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.lz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.xz
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.tar.zst
dexon-b708ec0f082d431dfe6d56882d58043811647ac7.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 {