Skip to content

Commit e939cf2

Browse files
committed
Remove atomic for m_last_getheaders_timestamp
This variable is only used in a single thread, so no atomic or mutex is necessary to guard it.
1 parent aeab1b4 commit e939cf2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/net_processing.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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<NodeClock::time_point> m_last_getheaders_timestamp{NodeSeconds{}};
361+
NodeClock::time_point m_last_getheaders_timestamp{};
362362

363363
Peer(NodeId id)
364364
: m_id{id}
@@ -2276,7 +2276,7 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const CBlockLocator& loc
22762276

22772277
// Only allow a new getheaders message to go out if we don't have a recent
22782278
// one already in-flight
2279-
if (current_time - peer.m_last_getheaders_timestamp.load() > HEADERS_RESPONSE_TIME) {
2279+
if (current_time - peer.m_last_getheaders_timestamp > HEADERS_RESPONSE_TIME) {
22802280
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETHEADERS, locator, uint256()));
22812281
peer.m_last_getheaders_timestamp = current_time;
22822282
return true;
@@ -3974,7 +3974,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
39743974

39753975
// Assume that this is in response to any outstanding getheaders
39763976
// request we may have sent, and clear out the time of our last request
3977-
peer->m_last_getheaders_timestamp.store(NodeSeconds{});
3977+
peer->m_last_getheaders_timestamp = {};
39783978

39793979
std::vector<CBlockHeader> headers;
39803980

0 commit comments

Comments
 (0)