aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
authors_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-08-20 16:55:14 +0000
committers_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>2010-08-20 16:55:14 +0000
commit2201a0808ea240617a66823f98dda3433d2546b0 (patch)
tree236085e71879b66b05bf3266a2b52f7322d104ff /util.cpp
parent05454818dc7ed92f577a1a1ef6798049f17a52e7 (diff)
downloadbitcoin-2201a0808ea240617a66823f98dda3433d2546b0.tar.xz
warning message if clock is too far off
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@141 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'util.cpp')
-rw-r--r--util.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/util.cpp b/util.cpp
index 8f06e30870..2be841d07c 100644
--- a/util.cpp
+++ b/util.cpp
@@ -14,6 +14,7 @@ char pszSetDataDir[MAX_PATH] = "";
bool fShutdown = false;
bool fDaemon = false;
bool fCommandLine = false;
+string strWarning;
@@ -742,14 +743,28 @@ void AddTimeData(unsigned int ip, int64 nTime)
{
sort(vTimeOffsets.begin(), vTimeOffsets.end());
int64 nMedian = vTimeOffsets[vTimeOffsets.size()/2];
- nTimeOffset = nMedian;
- if ((nMedian > 0 ? nMedian : -nMedian) > 70 * 60)
+ // Only let other nodes change our time by so much
+ if (abs64(nMedian) < 70 * 60)
+ {
+ nTimeOffset = nMedian;
+ }
+ else
{
- // Only let other nodes change our clock so far before we
- // go to the NTP servers
- /// todo: Get time from NTP servers, then set a flag
- /// to make sure it doesn't get changed again
nTimeOffset = 0;
+ // If nobody else has the same time as us, give a warning
+ bool fMatch = false;
+ foreach(int64 nOffset, vTimeOffsets)
+ if (nOffset != 0 && abs64(nOffset) < 10 * 60)
+ fMatch = true;
+ static bool fDone;
+ if (!fMatch && !fDone)
+ {
+ fDone = true;
+ string strMessage = _("Warning: Check your system date and time, you may not be able to generate or receive the most recent blocks!");
+ strWarning = strMessage;
+ printf("*** %s\n", strMessage.c_str());
+ boost::thread(bind(ThreadSafeMessageBox, strMessage+" ", string("Bitcoin"), wxOK | wxICON_EXCLAMATION, (wxWindow*)NULL, -1, -1));
+ }
}
foreach(int64 n, vTimeOffsets)
printf("%+"PRI64d" ", n);