mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
[net processing] Move fPreferHeaders from CNodeState to Peer
This commit is contained in:
parent
3605011e79
commit
8a2cb1f749
1 changed files with 6 additions and 6 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Reference in a new issue