@@ -358,7 +358,7 @@ struct Peer {
358
358
std::deque<CInv> m_getdata_requests GUARDED_BY (m_getdata_requests_mutex);
359
359
360
360
/* * Time of the last getheaders message to this peer */
361
- std::atomic<std::chrono::seconds > m_last_getheaders_timestamp{0s };
361
+ std::atomic<NodeClock::time_point > m_last_getheaders_timestamp{NodeSeconds{} };
362
362
363
363
Peer (NodeId id)
364
364
: m_id{id}
@@ -2272,10 +2272,11 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const CBlockLocator& loc
2272
2272
{
2273
2273
const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
2274
2274
2275
- const auto current_time = GetTime<std::chrono::seconds>();
2275
+ const auto current_time = NodeClock::now ();
2276
+
2276
2277
// Only allow a new getheaders message to go out if we don't have a recent
2277
2278
// one already in-flight
2278
- if (peer.m_last_getheaders_timestamp .load () < current_time - HEADERS_RESPONSE_TIME) {
2279
+ if (current_time - peer.m_last_getheaders_timestamp .load () > HEADERS_RESPONSE_TIME) {
2279
2280
m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::GETHEADERS, locator, uint256 ()));
2280
2281
peer.m_last_getheaders_timestamp = current_time;
2281
2282
return true ;
@@ -3973,7 +3974,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3973
3974
3974
3975
// Assume that this is in response to any outstanding getheaders
3975
3976
// request we may have sent, and clear out the time of our last request
3976
- peer->m_last_getheaders_timestamp = 0s ;
3977
+ peer->m_last_getheaders_timestamp . store (NodeSeconds{}) ;
3977
3978
3978
3979
std::vector<CBlockHeader> headers;
3979
3980
0 commit comments