diff options
Diffstat (limited to 'dex/blockproposer.go')
-rw-r--r-- | dex/blockproposer.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 762707aac..122540ba5 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -196,6 +196,7 @@ Loop: defer sub.Unsubscribe() // Listen chain head event until synced. + nextDMoment := time.Now().Unix() ListenLoop: for { select { @@ -238,6 +239,19 @@ ListenLoop: case <-b.watchCat.Meow(): log.Info("WatchCat signaled to stop syncing") + // Sleep until the next consensus start time slot. + // The interval T_i need to meet the following requirement: + // + // T_i > T_timeout + T_panic + T_restart + // + // Currently, T_timeout = 120, T_panic = 60, T_restart ~ 60 + // + // We set T_i = 600 to be safe. + + interval := int64(600) + nextDMoment = (time.Now().Unix()/interval + 1) * interval + log.Info("Sleeping until next starting time", "time", nextDMoment) + b.dex.protocolManager.SetReceiveCoreMessage(true) consensusSync.ForceSync(b.watchCat.LastPosition(), true) break ListenLoop @@ -245,5 +259,6 @@ ListenLoop: } con, err := consensusSync.GetSyncedConsensus() + time.Sleep(time.Duration(nextDMoment-time.Now().Unix()) * time.Second) return con, err } |