diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-03 13:42:25 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:59 +0800 |
commit | fbe6ddc62f7ebed15c6705f108d36d889c15e73d (patch) | |
tree | feea9a82228ea341d624e9c79a2218ef7ca6f440 /dex | |
parent | e02415d6224060ca9d7c3cef9005c729ac6b6c05 (diff) | |
download | dexon-fbe6ddc62f7ebed15c6705f108d36d889c15e73d.tar.gz dexon-fbe6ddc62f7ebed15c6705f108d36d889c15e73d.tar.zst dexon-fbe6ddc62f7ebed15c6705f108d36d889c15e73d.zip |
dex: get synced consensus before sleep (#331)
Diffstat (limited to 'dex')
-rw-r--r-- | dex/blockproposer.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go index c035eda7c..0b66a6cc1 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -193,6 +193,7 @@ Loop: log.Debug("Listen chain head event until synced") + nextDMoment := time.Now().Unix() // Listen chain head event until synced. ListenLoop: for { @@ -244,9 +245,8 @@ ListenLoop: // We set T_i = 600 to be safe. interval := int64(600) - nextDMoment := (time.Now().Unix()/interval + 1) * interval + nextDMoment = (time.Now().Unix()/interval + 1) * interval log.Info("Sleeping until next starting time", "time", nextDMoment) - time.Sleep(time.Duration(nextDMoment-time.Now().Unix()) * time.Second) b.dex.protocolManager.SetReceiveCoreMessage(true) consensusSync.ForceSync(true) @@ -254,5 +254,7 @@ ListenLoop: } } - return consensusSync.GetSyncedConsensus() + con, err := consensusSync.GetSyncedConsensus() + time.Sleep(time.Duration(nextDMoment-time.Now().Unix()) * time.Second) + return con, err } |