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 13:50:03 +0800
commita85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58 (patch)
tree34b35cadcc10da359acce130848fb08023a79638 /dex/handler.go
parent775393eea8e5d0509536e1a0cb1c68e6d3425581 (diff)
downloaddexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar.gz
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar.bz2
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar.lz
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar.xz
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.tar.zst
dexon-a85a386fbfb093bc8b0dd92b8a7b0fc5f5d92b58.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 {