Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ struct Peer {
std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);

/** Time of the last getheaders message to this peer */
std::atomic<std::chrono::seconds> m_last_getheaders_timestamp GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0s};
NodeClock::time_point m_last_getheaders_timestamp{}

explicit Peer(NodeId id, ServiceFlags our_services)
: m_id(id)
Expand Down Expand Up @@ -2988,10 +2988,10 @@ bool PeerManagerImpl::MaybeSendGetHeaders(CNode& pfrom, const std::string& msg_t

const CNetMsgMaker msgMaker(pfrom.GetCommonVersion());

const auto current_time = GetTime<std::chrono::seconds>();
const auto current_time = NodeClock::now();
// Only allow a new getheaders message to go out if we don't have a recent
// one already in-flight
if (peer.m_last_getheaders_timestamp.load() < current_time - HEADERS_RESPONSE_TIME) {
if (current_time - peer.m_last_getheaders_timestamp > HEADERS_RESPONSE_TIME) {
m_connman.PushMessage(&pfrom, msgMaker.Make(msg_type, locator, uint256()));
peer.m_last_getheaders_timestamp = current_time;
return true;
Expand Down Expand Up @@ -4883,7 +4883,7 @@ void PeerManagerImpl::ProcessMessage(

// Assume that this is in response to any outstanding getheaders
// request we may have sent, and clear out the time of our last request
peer->m_last_getheaders_timestamp = 0s;
peer->m_last_getheaders_timestamp = {};

std::vector<CBlockHeader> headers;

Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run_test(self):
msg.hashstop = 0
peer.send_and_ping(msg)
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.generate(self.nodes[0], 1)
Expand Down
Loading