Skip to content

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

Merged
laanwj merged 1 commit into
bitcoin:masterfrom
casey:bad-system-time-fix
Aug 5, 2015
Merged

Give a better error message if system clock is bad#6489
laanwj merged 1 commit into
bitcoin:masterfrom
casey:bad-system-time-fix

Conversation

@casey

@casey casey commented Jul 28, 2015

Copy link
Copy Markdown
Contributor

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

sipa commented Jul 28, 2015

Copy link
Copy Markdown
Member

You do need cs_main for that.

Comment thread src/init.cpp Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, okay. Fixed.

@laanwj

laanwj commented Jul 29, 2015

Copy link
Copy Markdown
Member

Concept ACK

@casey

casey commented Jul 29, 2015

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/init.cpp Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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");

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

casey commented Aug 3, 2015

Copy link
Copy Markdown
Contributor Author

Changed to use less ridiculously long strings.

@laanwj

laanwj commented Aug 3, 2015

Copy link
Copy Markdown
Member

utACK

1 similar comment
@sipa

sipa commented Aug 3, 2015

Copy link
Copy Markdown
Member

utACK

@fanquake

fanquake commented Aug 4, 2015

Copy link
Copy Markdown
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).

@laanwj laanwj merged commit f261f19 into bitcoin:master Aug 5, 2015
laanwj added a commit that referenced this pull request Aug 5, 2015
f261f19 Give a better error message if system clock is bad (Casey Rodarmor)
Comment thread src/init.cpp

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computer's is some weird grammar, no?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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.
zkbot added a commit to zcash/zcash that referenced this pull request Dec 4, 2019
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#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.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(serious) bug with wrong system clock

6 participants