File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,6 @@ int64_t GetAdjustedTime()
36
36
return GetTime () + GetTimeOffset ();
37
37
}
38
38
39
- static int64_t abs64 (int64_t n)
40
- {
41
- return (n >= 0 ? n : -n);
42
- }
43
-
44
39
#define BITCOIN_TIMEDATA_MAX_SAMPLES 200
45
40
46
41
void AddTimeData (const CNetAddr& ip, int64_t nOffsetSample)
@@ -79,7 +74,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
79
74
int64_t nMedian = vTimeOffsets.median ();
80
75
std::vector<int64_t > vSorted = vTimeOffsets.sorted ();
81
76
// Only let other nodes change our time by so much
82
- if (abs64 (nMedian) <= std::max<int64_t >(0 , gArgs .GetArg (" -maxtimeadjustment" , DEFAULT_MAX_TIME_ADJUSTMENT))) {
77
+ int64_t max_adjustment = std::max<int64_t >(0 , gArgs .GetArg (" -maxtimeadjustment" , DEFAULT_MAX_TIME_ADJUSTMENT));
78
+ if (nMedian >= -max_adjustment && nMedian <= max_adjustment) {
83
79
nTimeOffset = nMedian;
84
80
} else {
85
81
nTimeOffset = 0 ;
@@ -89,7 +85,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
89
85
// If nobody has a time different than ours but within 5 minutes of ours, give a warning
90
86
bool fMatch = false ;
91
87
for (const int64_t nOffset : vSorted) {
92
- if (nOffset != 0 && abs64 ( nOffset) < 5 * 60 ) fMatch = true ;
88
+ if (nOffset != 0 && nOffset > - 5 * 60 && nOffset < 5 * 60 ) fMatch = true ;
93
89
}
94
90
95
91
if (!fMatch ) {
You can’t perform that action at this time.
0 commit comments