diff options
author | dergoegge <n.goeggi@gmail.com> | 2022-09-20 14:37:27 +0100 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2023-03-30 14:56:19 +0200 |
commit | 8a2cb1f749ade31bb0655567cd0062db8a7164e5 (patch) | |
tree | 8bb7f532ffa50cd08b7aba392b62fefddfbf8561 /src/net_processing.cpp | |
parent | 3605011e79d0d43ff532a2c3cc9cad4cc48eb06c (diff) |
[net processing] Move fPreferHeaders from CNodeState to Peer
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index d9d4d3f5ea..f6fa9e25c3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -391,6 +391,9 @@ struct Peer { /** When to potentially disconnect peer for stalling headers download */ std::chrono::microseconds m_headers_sync_timeout GUARDED_BY(NetEventsInterface::g_msgproc_mutex){0us}; + /** Whether this peer wants invs or headers (when possible) for block announcements */ + bool fPreferHeaders GUARDED_BY(NetEventsInterface::g_msgproc_mutex){false}; + explicit Peer(NodeId id, ServiceFlags our_services) : m_id{id} , m_our_services{our_services} @@ -430,8 +433,6 @@ struct CNodeState { int nBlocksInFlight{0}; //! Whether we consider this a preferred download peer. bool fPreferredDownload{false}; - //! Whether this peer wants invs or headers (when possible) for block announcements. - bool fPreferHeaders GUARDED_BY(NetEventsInterface::g_msgproc_mutex){false}; /** Whether this peer wants invs or cmpctblocks (when possible) for block announcements. */ bool m_requested_hb_cmpctblocks{false}; /** Whether this peer will send us cmpctblocks if we request them. */ @@ -3447,8 +3448,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, } if (msg_type == NetMsgType::SENDHEADERS) { - LOCK(cs_main); - State(pfrom.GetId())->fPreferHeaders = true; + peer->fPreferHeaders = true; return; } @@ -5454,7 +5454,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) // add all to the inv queue. LOCK(peer->m_block_inv_mutex); std::vector<CBlock> vHeaders; - bool fRevertToInv = ((!state.fPreferHeaders && + bool fRevertToInv = ((!peer->fPreferHeaders && (!state.m_requested_hb_cmpctblocks || peer->m_blocks_for_headers_relay.size() > 1)) || peer->m_blocks_for_headers_relay.size() > MAX_BLOCKS_TO_ANNOUNCE); const CBlockIndex *pBestIndex = nullptr; // last header queued for delivery @@ -5531,7 +5531,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto) m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, cmpctblock)); } state.pindexBestHeaderSent = pBestIndex; - } else if (state.fPreferHeaders) { + } else if (peer->fPreferHeaders) { if (vHeaders.size() > 1) { LogPrint(BCLog::NET, "%s: %u headers, range (%s, %s), to peer=%d\n", __func__, vHeaders.size(), |