mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Check roughtime more frequently when there is a large clock offset (#6879)
* recheck roughtime more frequently if we think our clock is far off * Merge refs/heads/master into faster-roughtime-corrections * gaz * Merge refs/heads/master into faster-roughtime-corrections * Merge refs/heads/master into faster-roughtime-corrections * Merge refs/heads/master into faster-roughtime-corrections
This commit is contained in:
parent
e492343ffd
commit
0d118df034
@ -6,7 +6,6 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/shared/roughtime",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//shared/runutil:go_default_library",
|
||||
"@com_github_cloudflare_roughtime//:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||
"@com_github_prometheus_client_golang//prometheus/promauto:go_default_library",
|
||||
|
@ -2,14 +2,12 @@
|
||||
package roughtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
rt "github.com/cloudflare/roughtime"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"github.com/prysmaticlabs/prysm/shared/runutil"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@ -43,7 +41,19 @@ var offsetsRejected = promauto.NewCounter(prometheus.CounterOpts{
|
||||
|
||||
func init() {
|
||||
recalibrateRoughtime()
|
||||
runutil.RunEvery(context.Background(), RecalibrationInterval, recalibrateRoughtime)
|
||||
go func() {
|
||||
for {
|
||||
wait := RecalibrationInterval
|
||||
// recalibrate every minute if there is a large skew.
|
||||
if offset > 2*time.Second {
|
||||
wait = 1 * time.Minute
|
||||
}
|
||||
select {
|
||||
case <-time.After(wait):
|
||||
recalibrateRoughtime()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func recalibrateRoughtime() {
|
||||
|
Loading…
Reference in New Issue
Block a user