Bitcoin Core 28.99.0
P2P Digital Currency
|
#include <timeoffsets.h>
Public Member Functions | |
TimeOffsets (node::Warnings &warnings) | |
void | Add (std::chrono::seconds offset) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Add a new time offset sample. More... | |
std::chrono::seconds | Median () const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Compute and return the median of the collected time offset samples. More... | |
bool | WarnIfOutOfSync () const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex) |
Raise warnings if the median time offset exceeds the warnings threshold. More... | |
Private Member Functions | |
std::deque< std::chrono::seconds > m_offsets | GUARDED_BY (m_mutex) |
The observed time differences between our local clock and those of our outbound peers. More... | |
Private Attributes | |
Mutex | m_mutex |
node::Warnings & | m_warnings |
Static Private Attributes | |
static constexpr size_t | MAX_SIZE {50} |
Maximum number of timeoffsets stored. More... | |
static constexpr std::chrono::minutes | WARN_THRESHOLD {10} |
Minimum difference between system and network time for a warning to be raised. More... | |
Definition at line 18 of file timeoffsets.h.
|
inline |
Definition at line 21 of file timeoffsets.h.
void TimeOffsets::Add | ( | std::chrono::seconds | offset | ) |
Add a new time offset sample.
Definition at line 22 of file timeoffsets.cpp.
|
inlineprivate |
The observed time differences between our local clock and those of our outbound peers.
A positive offset means our peer's clock is ahead of our local clock.
Definition at line 32 of file timeoffsets.h.
std::chrono::seconds TimeOffsets::Median | ( | ) | const |
Compute and return the median of the collected time offset samples.
The median is returned as 0 when there are less than 5 samples.
Definition at line 34 of file timeoffsets.cpp.
bool TimeOffsets::WarnIfOutOfSync | ( | ) | const |
Raise warnings if the median time offset exceeds the warnings threshold.
Returns true if warnings were raised.
Definition at line 46 of file timeoffsets.cpp.
|
mutableprivate |
Definition at line 29 of file timeoffsets.h.
|
private |
Definition at line 34 of file timeoffsets.h.
|
staticconstexprprivate |
Maximum number of timeoffsets stored.
Definition at line 25 of file timeoffsets.h.
|
staticconstexprprivate |
Minimum difference between system and network time for a warning to be raised.
Definition at line 27 of file timeoffsets.h.