@ -80,7 +80,6 @@ bool fServer = false;
@@ -80,7 +80,6 @@ bool fServer = false;
string strMiscWarning ;
bool fNoListen = false ;
bool fLogTimestamps = false ;
CMedianFilter < int64 > vTimeOffsets ( 200 , 0 ) ;
volatile bool fReopenDebugLog = false ;
// Init OpenSSL library multithreading support
@ -1305,10 +1304,12 @@ void SetMockTime(int64 nMockTimeIn)
@@ -1305,10 +1304,12 @@ void SetMockTime(int64 nMockTimeIn)
nMockTime = nMockTimeIn ;
}
static CCriticalSection cs_nTimeOffset ;
static int64 nTimeOffset = 0 ;
int64 GetTimeOffset ( )
{
LOCK ( cs_nTimeOffset ) ;
return nTimeOffset ;
}
@ -1321,12 +1322,14 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
@@ -1321,12 +1322,14 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
{
int64 nOffsetSample = nTime - GetTime ( ) ;
LOCK ( cs_nTimeOffset ) ;
// Ignore duplicates
static set < CNetAddr > setKnown ;
if ( ! setKnown . insert ( ip ) . second )
return ;
// Add data
static CMedianFilter < int64 > vTimeOffsets ( 200 , 0 ) ;
vTimeOffsets . input ( nOffsetSample ) ;
LogPrintf ( " Added time data, samples %d, offset %+ " PRI64d " (%+ " PRI64d " minutes) \n " , vTimeOffsets . size ( ) , nOffsetSample , nOffsetSample / 60 ) ;
if ( vTimeOffsets . size ( ) > = 5 & & vTimeOffsets . size ( ) % 2 = = 1 )