aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2017-01-16 15:01:37 -0500
committerfanquake <fanquake@gmail.com>2021-02-17 12:26:04 +0800
commit3c2e16be22ae04bf56663ee5ec1554d0d569741b (patch)
tree826d344a5874a6a7c2e71c384288ac4bbc696275 /src/init.cpp
parent36be9b821ae0882ba5ccba543f959636e413991d (diff)
downloadbitcoin-3c2e16be22ae04bf56663ee5ec1554d0d569741b.tar.xz
time: add runtime sanity check
std::chrono::system_clock.time_since_epoch and time_t(0) are not guaranteed to use the Unix epoch timestamp, but in practice they almost certainly will. Any differing behavior will be assumed to be an error, unless certain platforms prove to consistently deviate, at which point we'll cope with it by adding offsets. Do a quick runtime check to verify that time_t(0) == std::chrono::system_clock's epoch time == unix epoch. Co-authored-by: Anthony Towns <aj@erisian.com.au>
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 96fb32ce2a..3beb421bf9 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -773,6 +773,10 @@ static bool InitSanityCheck()
return InitError(Untranslated("OS cryptographic RNG sanity check failure. Aborting."));
}
+ if (!ChronoSanityCheck()) {
+ return InitError(Untranslated("Clock epoch mismatch. Aborting."));
+ }
+
return true;
}