aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorstickies-v <stickies-v@protonmail.com>2024-02-03 17:15:41 +0000
committerstickies-v <stickies-v@protonmail.com>2024-04-10 16:15:46 +0200
commit55361a15d1aa6984051441bce88112000688fb43 (patch)
tree28eab9ca3974271e6ae563c186cc8f687b4522c7 /src/net_processing.cpp
parent038fd979effb54ee76ce1b7cf078e920c652326a (diff)
[net processing] Use std::chrono for type-safe time offsets
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index fe48aa25a9..363de48022 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -392,7 +392,7 @@ struct Peer {
/** Time offset computed during the version handshake based on the
* timestamp the peer sent in the version message. */
- std::atomic<int64_t> m_time_offset{0};
+ std::atomic<std::chrono::seconds> m_time_offset{0s};
explicit Peer(NodeId id, ServiceFlags our_services)
: m_id{id}
@@ -3671,11 +3671,11 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
peer->m_starting_height, addrMe.ToStringAddrPort(), fRelay, pfrom.GetId(),
remoteAddr, (mapped_as ? strprintf(", mapped_as=%d", mapped_as) : ""));
- peer->m_time_offset = nTime - GetTime();
+ peer->m_time_offset = NodeSeconds{std::chrono::seconds{nTime}} - Now<NodeSeconds>();
if (!pfrom.IsInboundConn()) {
// Don't use timedata samples from inbound peers to make it
// harder for others to tamper with our adjusted time.
- AddTimeData(pfrom.addr, peer->m_time_offset);
+ AddTimeData(pfrom.addr, Ticks<std::chrono::seconds>(peer->m_time_offset.load()));
}
// If the peer is old enough to have the old alert system, send it the final alert.