Bitcoin Core  27.99.0
P2P Digital Currency
Macros | Functions | Variables
timedata.cpp File Reference
#include <timedata.h>
#include <common/args.h>
#include <logging.h>
#include <netaddress.h>
#include <node/interface_ui.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/translation.h>
#include <warnings.h>
Include dependency graph for timedata.cpp:

Go to the source code of this file.

Macros

#define BITCOIN_TIMEDATA_MAX_SAMPLES   200
 

Functions

static int64_t nTimeOffset GUARDED_BY (g_timeoffset_mutex)=0
 
int64_t GetTimeOffset ()
 "Never go to sea with two chronometers; take one or three." Our three time sources are: More...
 
void AddTimeData (const CNetAddr &ip, int64_t nOffsetSample)
 
void TestOnlyResetTimeData ()
 Reset the internal state of GetTimeOffset() and AddTimeData(). More...
 

Variables

static GlobalMutex g_timeoffset_mutex
 
static std::set< CNetAddrg_sources
 
static CMedianFilter< int64_t > g_time_offsets {BITCOIN_TIMEDATA_MAX_SAMPLES, 0}
 
static bool g_warning_emitted
 

Macro Definition Documentation

◆ BITCOIN_TIMEDATA_MAX_SAMPLES

#define BITCOIN_TIMEDATA_MAX_SAMPLES   200

Definition at line 36 of file timedata.cpp.

Function Documentation

◆ AddTimeData()

void AddTimeData ( const CNetAddr ip,
int64_t  nOffsetSample 
)

Definition at line 42 of file timedata.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTimeOffset()

int64_t GetTimeOffset ( )

"Never go to sea with two chronometers; take one or three." Our three time sources are:

Functions to keep track of adjusted P2P time.

  • System clock
  • Median of other nodes clocks
  • The user (asking the user to fix the system clock if the first two disagree)

Definition at line 30 of file timedata.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY()

static int64_t nTimeOffset GUARDED_BY ( g_timeoffset_mutex  )
staticpure virtual

◆ TestOnlyResetTimeData()

void TestOnlyResetTimeData ( )

Reset the internal state of GetTimeOffset() and AddTimeData().

Definition at line 109 of file timedata.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ g_sources

std::set<CNetAddr> g_sources
static

Definition at line 38 of file timedata.cpp.

◆ g_time_offsets

CMedianFilter<int64_t> g_time_offsets {BITCOIN_TIMEDATA_MAX_SAMPLES, 0}
static

Definition at line 39 of file timedata.cpp.

◆ g_timeoffset_mutex

GlobalMutex g_timeoffset_mutex
static

Definition at line 20 of file timedata.cpp.

◆ g_warning_emitted

bool g_warning_emitted
static

Definition at line 40 of file timedata.cpp.