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

Give a better error message if system clock is bad #6489

Merged
merged 1 commit into from Aug 5, 2015

Conversation

Projects
None yet
7 participants
@casey
Contributor

casey commented Jul 28, 2015

Fixes #2007

This checks to see if the system clock appears to be bad and gives a
helpful error message. If the user's clock is set incorrectly, hopefully
they'll abort, fix it, and then save themselves a fruitless resync.

I wasn't sure if I needed to grab cs_main before accessing chainActive.Tip(), is that correct?

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Jul 28, 2015

Member

You do need cs_main for that.

Member

sipa commented Jul 28, 2015

You do need cs_main for that.

@laanwj

View changes

Show outdated Hide outdated src/init.cpp
LOCK(cs_main);
CBlockIndex* tip = chainActive.Tip();
CBlock block;
if (tip && ReadBlockFromDisk(block, tip)) {

This comment has been minimized.

@laanwj

laanwj Jul 29, 2015

Member

Any specific reason to read the block from disk here? Reminder: tip itself, a CBlockIndex, also has nTime

@laanwj

laanwj Jul 29, 2015

Member

Any specific reason to read the block from disk here? Reminder: tip itself, a CBlockIndex, also has nTime

This comment has been minimized.

@casey

casey Jul 29, 2015

Contributor

Ahh, okay. Fixed.

@casey

casey Jul 29, 2015

Contributor

Ahh, okay. Fixed.

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Jul 29, 2015

Member

Concept ACK

Member

laanwj commented Jul 29, 2015

Concept ACK

@casey

This comment has been minimized.

Show comment
Hide comment
@casey

casey Jul 29, 2015

Contributor

Updated the commit to use chainActive.Tip()->nTime directly

Contributor

casey commented Jul 29, 2015

Updated the commit to use chainActive.Tip()->nTime directly

@bensussman

View changes

Show outdated Hide outdated src/init.cpp
LOCK(cs_main);
CBlockIndex* tip = chainActive.Tip();
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
strLoadError = _("The block database contains a block which appears to be from the future. This may be due to your computer's date and time being set incorrectly. Only rebuild the block database if you are sure that your computer's date and time are correct");

This comment has been minimized.

@bensussman

bensussman Jul 30, 2015

Is there no styleguide for the bitcoin codebase that says ">250 character lines are just TOO LONG @casey"?!

@bensussman

bensussman Jul 30, 2015

Is there no styleguide for the bitcoin codebase that says ">250 character lines are just TOO LONG @casey"?!

This comment has been minimized.

@casey

casey Jul 30, 2015

Contributor

This string is going to be translated via gettext (that's what the "_" is for) so it's better than it appear in the source as one line, as opposed to being broken up.

@casey

casey Jul 30, 2015

Contributor

This string is going to be translated via gettext (that's what the "_" is for) so it's better than it appear in the source as one line, as opposed to being broken up.

This comment has been minimized.

@laanwj

laanwj Jul 31, 2015

Member

@bensussman To answer your question: no, there is no such rule. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md

@casey Using multiple "line" "line2" line3" does not affect translation IIRC if you specify only one _, eg:

strLoadError = _("The block database contains a block which appears to be from the future. "
    "This may be due to your computer's date and time being set incorrectly. "
    "Only rebuild the block database if you are sure that your computer's date and time are correct");
@laanwj

laanwj Jul 31, 2015

Member

@bensussman To answer your question: no, there is no such rule. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md

@casey Using multiple "line" "line2" line3" does not affect translation IIRC if you specify only one _, eg:

strLoadError = _("The block database contains a block which appears to be from the future. "
    "This may be due to your computer's date and time being set incorrectly. "
    "Only rebuild the block database if you are sure that your computer's date and time are correct");
Give a better error message if system clock is bad
Fixes #2007

This checks to see if the system clock appears to be bad and gives a
helpful error message. If the user's clock is set incorrectly, hopefully
they'll abort, fix it, and then save themselves a fruitless resync.
@casey

This comment has been minimized.

Show comment
Hide comment
@casey

casey Aug 3, 2015

Contributor

Changed to use less ridiculously long strings.

Contributor

casey commented Aug 3, 2015

Changed to use less ridiculously long strings.

@laanwj

This comment has been minimized.

Show comment
Hide comment
@laanwj

laanwj Aug 3, 2015

Member

utACK

Member

laanwj commented Aug 3, 2015

utACK

@sipa

This comment has been minimized.

Show comment
Hide comment
@sipa

sipa Aug 3, 2015

Member

utACK

Member

sipa commented Aug 3, 2015

utACK

@fanquake

This comment has been minimized.

Show comment
Hide comment
@fanquake

fanquake Aug 4, 2015

Member

utACK

On Tuesday, August 4, 2015, Pieter Wuille notifications@github.com wrote:

utACK


Reply to this email directly or view it on GitHub
#6489 (comment).

Member

fanquake commented Aug 4, 2015

utACK

On Tuesday, August 4, 2015, Pieter Wuille notifications@github.com wrote:

utACK


Reply to this email directly or view it on GitHub
#6489 (comment).

@laanwj laanwj merged commit f261f19 into bitcoin:master Aug 5, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Aug 5, 2015

Merge pull request #6489
f261f19 Give a better error message if system clock is bad (Casey Rodarmor)
CBlockIndex* tip = chainActive.Tip();
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
strLoadError = _("The block database contains a block which appears to be from the future. "
"This may be due to your computer's date and time being set incorrectly. "

This comment has been minimized.

@Diapolo

Diapolo Aug 5, 2015

computer's is some weird grammar, no?

@Diapolo

Diapolo Aug 5, 2015

computer's is some weird grammar, no?

This comment has been minimized.

@NanoAkron

NanoAkron Aug 5, 2015

Not really. It indicates that the computer is the owner of the date & time, which in this case it is.

@NanoAkron

NanoAkron Aug 5, 2015

Not really. It indicates that the computer is the owner of the date & time, which in this case it is.

zkbot added a commit to zcash/zcash that referenced this pull request Mar 21, 2018

Auto merge of #2390 - str4d:2132-mapargs-prep, r=<try>
Misc upstream PRs

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6077
  - Second commit only (first was already applied to 0.11.X and then reverted)
- bitcoin/bitcoin#6284
- bitcoin/bitcoin#6489
- bitcoin/bitcoin#6462
- bitcoin/bitcoin#6647
- bitcoin/bitcoin#6235
- bitcoin/bitcoin#6905
- bitcoin/bitcoin#6780
  - Excluding second commit (QT) and third commit (requires bitcoin/bitcoin#6993)
- bitcoin/bitcoin#6961
  - Excluding QT parts, and a small `src/policy/policy.cpp` change which depends on a bunch of other PRs, which we'll have to remember to come back to.
- bitcoin/bitcoin#7044
- bitcoin/bitcoin#8856
- bitcoin/bitcoin#9002

Part of #2074 and #2132.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment