aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2019-01-02 18:56:02 +0800
committerWei-Ning Huang <w@dexon.org>2019-01-02 18:56:02 +0800
commit3c3e5d0b11758e2385b3890013be3e3698b992a8 (patch)
treef994e7dbeb7d0732116e0de536b12b53273bedab /core
parentf12b6cf891181a72914b3aec8caf7ae0879f6000 (diff)
downloaddexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar.gz
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar.bz2
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar.lz
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar.xz
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.tar.zst
dexon-consensus-3c3e5d0b11758e2385b3890013be3e3698b992a8.zip
Fix TODO (#390)
Diffstat (limited to 'core')
-rw-r--r--core/consensus.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/consensus.go b/core/consensus.go
index 3353d1d..faadbe9 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -563,14 +563,17 @@ func (con *Consensus) prepare(initBlock *types.Block) error {
if err != nil {
return err
}
- // TODO(jimmy): registerDKG should be called after dmoment.
if _, exist := dkgSet[con.ID]; exist {
con.logger.Info("Selected as DKG set", "round", initRound)
- con.cfgModule.registerDKG(initRound, getDKGThreshold(initConfig))
- con.event.RegisterTime(con.dMoment.Add(initConfig.RoundInterval/4),
- func(time.Time) {
- con.runDKG(initRound, initConfig)
- })
+ go func() {
+ // Sleep until dMoment come.
+ time.Sleep(con.dMoment.Sub(time.Now().UTC()))
+ con.cfgModule.registerDKG(initRound, getDKGThreshold(initConfig))
+ con.event.RegisterTime(con.dMoment.Add(initConfig.RoundInterval/4),
+ func(time.Time) {
+ con.runDKG(initRound, initConfig)
+ })
+ }()
}
con.initialRound(con.dMoment, initRound, initConfig)
return nil