@@ -358,7 +358,7 @@ struct Peer {
358358 std::deque<CInv> m_getdata_requests GUARDED_BY (m_getdata_requests_mutex);
359359
360360 /* * 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{} };
362362
363363 Peer (NodeId id)
364364 : m_id{id}
@@ -2272,10 +2272,11 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const CBlockLocator& loc
22722272{
22732273 const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
22742274
2275- const auto current_time = GetTime<std::chrono::seconds>();
2275+ const auto current_time = NodeClock::now ();
2276+
22762277 // Only allow a new getheaders message to go out if we don't have a recent
22772278 // 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) {
22792280 m_connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::GETHEADERS, locator, uint256 ()));
22802281 peer.m_last_getheaders_timestamp = current_time;
22812282 return true ;
@@ -3973,7 +3974,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
39733974
39743975 // Assume that this is in response to any outstanding getheaders
39753976 // 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{}) ;
39773978
39783979 std::vector<CBlockHeader> headers;
39793980
0 commit comments