Merge pull request #297 from dinhln89/delay

Fixed delay longer than 10 seconds when near at block checkpoint.
This commit is contained in:
Tuna 2018-11-23 09:40:05 +07:00 committed by GitHub
commit 2cd7af7193
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,6 +54,8 @@ const (
chainSideChanSize = 10
// timeout waiting for M1
waitPeriod = 10
// timeout for checkpoint.
waitPeriodCheckpoint = 60
)
// Agent can register themself with the worker
@ -495,6 +497,11 @@ func (self *worker) commitNewWork() {
}
h := hop(len(masternodes), preIndex, curIndex)
gap := waitPeriod * int64(h)
// Check nearest checkpoint block in hop range.
nearest := self.config.Posv.Epoch - (parent.Header().Number.Uint64() % self.config.Posv.Epoch)
if uint64(h) >= nearest {
gap += waitPeriodCheckpoint
}
log.Info("Distance from the parent block", "seconds", gap, "hops", h)
L:
select {