15
15
#include < util/translation.h>
16
16
#include < warnings.h>
17
17
18
-
19
18
static Mutex g_timeoffset_mutex;
20
19
static int64_t nTimeOffset GUARDED_BY (g_timeoffset_mutex) = 0;
21
20
@@ -57,7 +56,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
57
56
// Add data
58
57
static CMedianFilter<int64_t > vTimeOffsets (BITCOIN_TIMEDATA_MAX_SAMPLES, 0 );
59
58
vTimeOffsets.input (nOffsetSample);
60
- LogPrint (BCLog::NET," added time data, samples %d, offset %+d (%+d minutes)\n " , vTimeOffsets.size (), nOffsetSample, nOffsetSample/ 60 );
59
+ LogPrint (BCLog::NET, " added time data, samples %d, offset %+d (%+d minutes)\n " , vTimeOffsets.size (), nOffsetSample, nOffsetSample / 60 );
61
60
62
61
// There is a known issue here (see issue #4521):
63
62
//
@@ -76,30 +75,24 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
76
75
// So we should hold off on fixing this and clean it up as part of
77
76
// a timing cleanup that strengthens it in a number of other ways.
78
77
//
79
- if (vTimeOffsets.size () >= 5 && vTimeOffsets.size () % 2 == 1 )
80
- {
78
+ if (vTimeOffsets.size () >= 5 && vTimeOffsets.size () % 2 == 1 ) {
81
79
int64_t nMedian = vTimeOffsets.median ();
82
80
std::vector<int64_t > vSorted = vTimeOffsets.sorted ();
83
81
// Only let other nodes change our time by so much
84
- if (abs64 (nMedian) <= std::max<int64_t >(0 , gArgs .GetArg (" -maxtimeadjustment" , DEFAULT_MAX_TIME_ADJUSTMENT)))
85
- {
82
+ if (abs64 (nMedian) <= std::max<int64_t >(0 , gArgs .GetArg (" -maxtimeadjustment" , DEFAULT_MAX_TIME_ADJUSTMENT))) {
86
83
nTimeOffset = nMedian;
87
- }
88
- else
89
- {
84
+ } else {
90
85
nTimeOffset = 0 ;
91
86
92
87
static bool fDone ;
93
- if (!fDone )
94
- {
88
+ if (!fDone ) {
95
89
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
96
90
bool fMatch = false ;
97
- for (const int64_t nOffset : vSorted)
98
- if (nOffset != 0 && abs64 (nOffset) < 5 * 60 )
99
- fMatch = true ;
91
+ for (const int64_t nOffset : vSorted) {
92
+ if (nOffset != 0 && abs64 (nOffset) < 5 * 60 ) fMatch = true ;
93
+ }
100
94
101
- if (!fMatch )
102
- {
95
+ if (!fMatch ) {
103
96
fDone = true ;
104
97
bilingual_str 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);
105
98
SetMiscWarning (strMessage.translated );
@@ -113,8 +106,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
113
106
LogPrint (BCLog::NET, " %+d " , n); /* Continued */
114
107
}
115
108
LogPrint (BCLog::NET, " | " ); /* Continued */
116
-
117
- LogPrint (BCLog::NET, " nTimeOffset = %+d (%+d minutes)\n " , nTimeOffset, nTimeOffset/60 );
109
+ LogPrint (BCLog::NET, " nTimeOffset = %+d (%+d minutes)\n " , nTimeOffset, nTimeOffset / 60 );
118
110
}
119
111
}
120
112
}
0 commit comments