aboutsummaryrefslogtreecommitdiff
path: root/util.cpp
diff options
context:
space:
mode:
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);