-
Notifications
You must be signed in to change notification settings - Fork 2
Improve time sync accuracy #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…-run-every-30s Fix timesync scheduling
| } | ||
| var minOffset = Math.min.apply(null, timeSyncSamples); | ||
| timeSyncSamples = []; | ||
| if (Math.abs(minOffset) > 3000000000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer the 3E9 syntax for large numbers. It is very annoying to count the zeros
| } | ||
|
|
||
| function parseCurrentTimeResponse(serverTime) { | ||
| var localNs = Date.now() * 1000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also 1E6
| timeSyncSamples = []; | ||
| if (Math.abs(minOffset) > 3000000000) { | ||
| setTimeOffset(minOffset); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be an else clause to reset the offset for the case previously due to some network issue offset was very high but now is under 3 seconds?
Summary