Skip to content
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

Investigate wallet clock skew handling #91

Open
shane-kerr opened this issue Sep 8, 2018 · 0 comments
Open

Investigate wallet clock skew handling #91

shane-kerr opened this issue Sep 8, 2018 · 0 comments

Comments

@shane-kerr
Copy link
Member

We have some code that is supposed to handle clock skew.

static int64 nTimeOffset = 0;

int64 GetAdjustedTime()
{
    return GetTime() + nTimeOffset;
}

void AddTimeData(const CNetAddr& ip, int64 nTime)
{
   // 50 lines of voodoo updating your clock from other nodes
}

We can see this being adjusted in the debug.log file:

Added time data, samples 2, offset -40 (+0 minutes)
Added time data, samples 3, offset -17 (+0 minutes)
dded time data, samples 4, offset -17 (+0 minutes)
Added time data, samples 5, offset -53 (+0 minutes)
nTimeOffset = -17  (+0 minutes)

However it goes wonky sometimes:

nTimeOffset = -51  (+0 minutes)
Added time data, samples 64, offset -27 (+0 minutes)
Added time data, samples 65, offset -14 (+0 minutes)
nTimeOffset = -51  (+0 minutes)
Added time data, samples 66, offset -1269 (-21 minutes)

This seems bad especially since on this computer the time was within 2 milliseconds of "true" time based on NTP.

One possibility is just to report clock skew if detected, but never to adjust.

In any case, research this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant