From 8be371db340b03dc03142c1bb3390fdfc84f56b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Jan=C3=ADk?= Date: Tue, 11 Aug 2015 15:57:52 +0200 Subject: Do not store more than 200 timedata samples. --- src/timedata.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index c3e9c75f6..a14d69c11 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -40,16 +40,20 @@ static int64_t abs64(int64_t n) return (n >= 0 ? n : -n); } +#define BITCOIN_TIMEDATA_MAX_SAMPLES 200 + void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) { LOCK(cs_nTimeOffset); // Ignore duplicates static set setKnown; + if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) + return; if (!setKnown.insert(ip).second) return; // Add data - static CMedianFilter vTimeOffsets(200,0); + static CMedianFilter vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0); vTimeOffsets.input(nOffsetSample); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); -- cgit v1.2.3 From 9fea833a1229f9657b96ef2f0a3fb6c20e790657 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 27 Sep 2015 16:40:16 +0200 Subject: timedata: Prevent warning overkill The "please check your computer's data and time" message when the clock deviates from the network currently generates an overkill of messages: orion@lethe:~/bitcoin$ src/bitcoind Warning: Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly. In the log: 2015-09-27 16:24:13 *** Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly. 2015-09-27 16:24:13 Warning: Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly. Remove one level of 'Warning:' and reduce to one log message. --- src/timedata.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index a14d69c11..064100953 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -99,9 +99,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (!fMatch) { fDone = true; - string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly."); + string strMessage = _("Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly."); strMiscWarning = strMessage; - LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } } -- cgit v1.2.3 From 4846543ac58c72ca5ec2b25e690c8e1a4247c048 Mon Sep 17 00:00:00 2001 From: tulip Date: Sun, 22 Nov 2015 06:48:25 +0000 Subject: Move time data log print to 'net' category to reduce log noise --- src/timedata.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 064100953..861c37598 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -55,7 +55,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) // Add data static CMedianFilter vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0); vTimeOffsets.input(nOffsetSample); - LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); + LogPrint("net","added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); // There is a known issue here (see issue #4521): // @@ -105,11 +105,11 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) } } } - if (fDebug) { - BOOST_FOREACH(int64_t n, vSorted) - LogPrintf("%+d ", n); - LogPrintf("| "); - } - LogPrintf("nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); + + BOOST_FOREACH(int64_t n, vSorted) + LogPrint("net", "%+d ", n); + LogPrint("net", "| "); + + LogPrint("net", "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); } } -- cgit v1.2.3 From fa24439ff3d8ab5b9efaf66ef4dae6713b88cb35 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 13 Dec 2015 17:58:29 +0100 Subject: Bump copyright headers to 2015 --- src/timedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 861c37598..de8cc62b2 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014 The Bitcoin Core developers +// Copyright (c) 2014-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From d5f46832de900cee0801ca40bba743c9564cccb8 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 9 Dec 2015 10:53:12 +0000 Subject: Unify package name to as few places as possible without major changes --- src/timedata.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 861c37598..2eaa9e4c8 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -2,6 +2,10 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#if defined(HAVE_CONFIG_H) +#include "config/bitcoin-config.h" +#endif + #include "timedata.h" #include "netbase.h" @@ -99,7 +103,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (!fMatch) { fDone = true; - string strMessage = _("Please check that your computer's date and time are correct! If your clock is wrong Bitcoin Core will not work properly."); + string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), _(PACKAGE_NAME)); strMiscWarning = strMessage; uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } -- cgit v1.2.3 From e1523cee5808bb792cd99f037f06b736af4e23fb Mon Sep 17 00:00:00 2001 From: mruddy Date: Tue, 29 Mar 2016 14:40:00 +0000 Subject: P2P: add maxtimeadjustment command line option --- src/timedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 4d2f8d1e3..b6bcf86fb 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -83,7 +83,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) int64_t nMedian = vTimeOffsets.median(); std::vector vSorted = vTimeOffsets.sorted(); // Only let other nodes change our time by so much - if (abs64(nMedian) < 70 * 60) + if (abs64(nMedian) <= std::max(0, GetArg("-maxtimeadjustment", DEFAULT_MAX_TIME_ADJUSTMENT))) { nTimeOffset = nMedian; } -- cgit v1.2.3 From 21ba407a7369a0229b8a8554dee0da63a64e6639 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 31 May 2016 17:42:38 -0400 Subject: net: narrow include scope after moving to netaddress Net functionality is no longer needed for CAddress/CAddrman/etc. now that CNetAddr/CService/CSubNet are dumb storage classes. --- src/timedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index b6bcf86fb..25fc49412 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -8,7 +8,7 @@ #include "timedata.h" -#include "netbase.h" +#include "netaddress.h" #include "sync.h" #include "ui_interface.h" #include "util.h" -- cgit v1.2.3 From e3ba0ef95636290a3bb597ddd25d13ea13b034aa Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Tue, 29 Nov 2016 09:46:19 +0000 Subject: Eliminate data races for strMiscWarning and fLargeWork*Found. This moves all access to these datastructures through accessor functions and protects them with a lock. --- src/timedata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 25fc49412..256c91016 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -103,8 +103,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (!fMatch) { fDone = true; - string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), _(PACKAGE_NAME)); - strMiscWarning = strMessage; + std::string strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), _(PACKAGE_NAME)); + SetMiscWarning(strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } } -- cgit v1.2.3 From 749be013f5cba0bbb01f1f89df77106aea5a4cc1 Mon Sep 17 00:00:00 2001 From: Gregory Maxwell Date: Wed, 30 Nov 2016 06:07:42 +0000 Subject: Move GetWarnings() into its own file. --- src/timedata.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index 256c91016..b3cbdcf88 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -13,6 +13,7 @@ #include "ui_interface.h" #include "util.h" #include "utilstrencodings.h" +#include "warnings.h" #include -- cgit v1.2.3 From 27765b6403cece54320374b37afb01a0cfe571c3 Mon Sep 17 00:00:00 2001 From: isle2983 Date: Sat, 31 Dec 2016 11:01:21 -0700 Subject: Increment MIT Licence copyright header year on files modified in 2016 Edited via: $ contrib/devtools/copyright_header.py update . --- src/timedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index b3cbdcf88..c72252e6d 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2015 The Bitcoin Core developers +// Copyright (c) 2014-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -- cgit v1.2.3 From b7b48c8bbdf7a90861610b035d8b0a247ef78c45 Mon Sep 17 00:00:00 2001 From: Karl-Johan Alm Date: Fri, 27 Jan 2017 17:43:41 +0900 Subject: Refactor: Remove using namespace from src/*.cpp. --- src/timedata.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/timedata.cpp') diff --git a/src/timedata.cpp b/src/timedata.cpp index c72252e6d..2ff6437c7 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -17,8 +17,6 @@ #include -using namespace std; - static CCriticalSection cs_nTimeOffset; static int64_t nTimeOffset = 0; @@ -51,7 +49,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) { LOCK(cs_nTimeOffset); // Ignore duplicates - static set setKnown; + static std::set setKnown; if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) return; if (!setKnown.insert(ip).second) -- cgit v1.2.3