Take a tick a little early as the network look's tick
The liveness loop's ticker drifts; a look skipped for a few milliseconds would wait a whole further tick.
This commit is contained in:
@@ -199,7 +199,8 @@ func (j *Judge) Look(ctx context.Context) (Statement, bool) {
|
||||
j.mu.Lock()
|
||||
defer j.mu.Unlock()
|
||||
now := j.m.Now()
|
||||
if !j.lookedAt.IsZero() && now.Sub(j.lookedAt) < LookEvery {
|
||||
// A tick a little early is still the tick: the loop that calls this runs on its own clock.
|
||||
if !j.lookedAt.IsZero() && now.Sub(j.lookedAt) < LookEvery-LookEvery/10 {
|
||||
return j.said, false
|
||||
}
|
||||
j.lookedAt = now
|
||||
|
||||
Reference in New Issue
Block a user