aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2019-04-03 13:42:25 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-15 22:09:55 +0800
commit359a404b587b25b863fe107d3f98c61863e6ea49 (patch)
treedd9166ee22b2f97f7cae8af65a8f088c63291ff4
parent2cc07197e4932c3201608026ebed43c4a4e79858 (diff)
downloadgo-tangerine-359a404b587b25b863fe107d3f98c61863e6ea49.tar.gz
go-tangerine-359a404b587b25b863fe107d3f98c61863e6ea49.tar.zst
go-tangerine-359a404b587b25b863fe107d3f98c61863e6ea49.zip
dex: get synced consensus before sleep (#331)
-rw-r--r--dex/blockproposer.go8
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
}