X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fntp.cpp;h=60cc309bc5b5994fdc54523d5c6ee5fe5306b5a8;hp=bae50d936f01e60d58585a7f0e95294ab84b9b24;hb=4ad19b65ee94035ec0b976e715d5ddb0ea778649;hpb=cc25738918efa366be574377b971d437659e6e2a diff --git a/src/ntp.cpp b/src/ntp.cpp index bae50d9..60cc309 100644 --- a/src/ntp.cpp +++ b/src/ntp.cpp @@ -81,7 +81,7 @@ struct pkt { const int nServersCount = 147; -const std::string NtpServers[147] = { +std::string NtpServers[147] = { // Microsoft "time.windows.com", @@ -262,7 +262,7 @@ const std::string NtpServers[147] = { // ... To be continued }; -bool InitWithHost(const std::string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) { +bool InitWithHost(std::string &strHostName, SOCKET &sockfd, socklen_t &servlen, struct sockaddr *pcliaddr) { sockfd = -1; std::vector vIP; @@ -391,7 +391,7 @@ int64_t NtpGetTime(CNetAddr& ip) { return nTime; } -int64_t NtpGetTime(const std::string &strHostName) +int64_t NtpGetTime(std::string &strHostName) { struct sockaddr cliaddr; @@ -426,7 +426,7 @@ void ThreadNtpSamples(void* parg) { printf("Trying to find NTP server at localhost...\n"); - const std::string strLocalHost = "127.0.0.1"; + std::string strLocalHost = "127.0.0.1"; if (NtpGetTime(strLocalHost) == GetTime()) { printf("There is NTP server active at localhost, we don't need NTP thread.\n"); @@ -443,7 +443,7 @@ void ThreadNtpSamples(void* parg) { CMedianFilter vTimeOffsets(200,0); while (!fShutdown) { - if (strTrustedUpstream != strLocalHost) { + if (strTrustedUpstream != "localhost") { // Trying to get new offset sample from trusted NTP server. int64_t nClockOffset = NtpGetTime(strTrustedUpstream) - GetTime(); @@ -455,7 +455,7 @@ void ThreadNtpSamples(void* parg) { else { // Something went wrong, disable trusted offset sampling. nNtpOffset = INT64_MAX; - strTrustedUpstream = strLocalHost; + strTrustedUpstream = "localhost"; int nSleepMinutes = 1 + GetRandInt(9); // Sleep for 1-10 minutes. for (int i = 0; i < nSleepMinutes * 60 && !fShutdown; i++)