mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
Merge bitcoin/bitcoin#25557: p2p: Eliminate atomic for m_last_getheaders_timestamp
613e221149
test: remove unnecessary parens (Suhas Daftuar)e939cf2b76
Remove atomic for m_last_getheaders_timestamp (Suhas Daftuar) Pull request description: Eliminate the unnecessary atomic guarding `m_last_getheaders_timestamp`, which is only accessed in a single thread (thanks to MarcoFalke for pointing this out). Also address a nit that came up in #25454. ACKs for top commit: MarcoFalke: review ACK613e221149
vasild: ACK613e221149
Tree-SHA512: 6d6c473735b450b8ad43aae5cf16ed419154d72f4a05c0a6ce6f26caecab9db2361041398b70bf9395611c107d50897f501fa5fdbabb2891144bbc2b479dfdad
This commit is contained in:
commit
8efa73e7ce
2 changed files with 4 additions and 4 deletions
|
@ -358,7 +358,7 @@ struct Peer {
|
||||||
std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);
|
std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);
|
||||||
|
|
||||||
/** Time of the last getheaders message to this peer */
|
/** Time of the last getheaders message to this peer */
|
||||||
std::atomic<NodeClock::time_point> m_last_getheaders_timestamp{NodeSeconds{}};
|
NodeClock::time_point m_last_getheaders_timestamp{};
|
||||||
|
|
||||||
Peer(NodeId id)
|
Peer(NodeId id)
|
||||||
: m_id{id}
|
: m_id{id}
|
||||||
|
@ -2276,7 +2276,7 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const CBlockLocator& loc
|
||||||
|
|
||||||
// Only allow a new getheaders message to go out if we don't have a recent
|
// Only allow a new getheaders message to go out if we don't have a recent
|
||||||
// one already in-flight
|
// one already in-flight
|
||||||
if (current_time - peer.m_last_getheaders_timestamp.load() > HEADERS_RESPONSE_TIME) {
|
if (current_time - peer.m_last_getheaders_timestamp > HEADERS_RESPONSE_TIME) {
|
||||||
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETHEADERS, locator, uint256()));
|
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETHEADERS, locator, uint256()));
|
||||||
peer.m_last_getheaders_timestamp = current_time;
|
peer.m_last_getheaders_timestamp = current_time;
|
||||||
return true;
|
return true;
|
||||||
|
@ -3974,7 +3974,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
|
|
||||||
// Assume that this is in response to any outstanding getheaders
|
// Assume that this is in response to any outstanding getheaders
|
||||||
// request we may have sent, and clear out the time of our last request
|
// request we may have sent, and clear out the time of our last request
|
||||||
peer->m_last_getheaders_timestamp.store(NodeSeconds{});
|
peer->m_last_getheaders_timestamp = {};
|
||||||
|
|
||||||
std::vector<CBlockHeader> headers;
|
std::vector<CBlockHeader> headers;
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ class MinimumChainWorkTest(BitcoinTestFramework):
|
||||||
msg.hashstop = 0
|
msg.hashstop = 0
|
||||||
peer.send_and_ping(msg)
|
peer.send_and_ping(msg)
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
assert ("headers" not in peer.last_message or len(peer.last_message["headers"].headers) == 0)
|
assert "headers" not in peer.last_message or len(peer.last_message["headers"].headers) == 0
|
||||||
|
|
||||||
self.log.info("Generating one more block")
|
self.log.info("Generating one more block")
|
||||||
self.generate(self.nodes[0], 1)
|
self.generate(self.nodes[0], 1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue