#include "netbase.h"
#include "net.h"
-#include "util.h"
+//#include "util.h"
+#include "ui_interface.h"
extern int GetRandInt(int nMax);
}
void ThreadNtpSamples(void* parg) {
-
- // Maximum offset is 2 hours.
- const int64_t nMaxOffset = 7200;
+ const int64_t nMaxOffset = 86400; // Not a real limit, just sanity threshold.
printf("Trying to find NTP server at localhost...\n");
}
}
+ if (GetNodesOffset() == INT_MAX && abs64(nNtpOffset) > 40 * 60)
+ {
+ // If there is not enough node offsets data and NTP time offset is greater than 40 minutes then give a warning.
+ std::string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong NovaCoin will not work properly.");
+ strMiscWarning = strMessage;
+ printf("*** %s\n", strMessage.c_str());
+ uiInterface.ThreadSafeMessageBox(strMessage+" ", std::string("NovaCoin"), CClientUIInterface::OK | CClientUIInterface::ICON_EXCLAMATION);
+ }
+
printf("nNtpOffset = %+" PRId64 " (%+" PRId64 " minutes)\n", nNtpOffset, nNtpOffset/60);
int nSleepHours = 1 + GetRandInt(5); // Sleep for 1-6 hours.
static int64_t nNodesOffset = INT64_MAX;
// Select time offset:
-//
-// * If NTP and system clock are in agreement within 40 minutes, then use NTP.
-// * If not, then choose between median peer time and system clock using the same condition.
int64_t GetTimeOffset()
{
+ // If NTP and system clock are in agreement within 40 minutes, then use NTP.
if (abs64(nNtpOffset) < 40 * 60)
return nNtpOffset;
- if (abs64(nNodesOffset) < 40 * 60)
+ // If not, then choose between median peer time and system clock.
+ if (abs64(nNodesOffset) < 70 * 60)
return nNodesOffset;
return 0;