@@ -391,6 +391,9 @@ struct Peer {
391
391
/* * When to potentially disconnect peer for stalling headers download */
392
392
std::chrono::microseconds m_headers_sync_timeout GUARDED_BY (NetEventsInterface::g_msgproc_mutex){0us};
393
393
394
+ /* * Whether this peer wants invs or headers (when possible) for block announcements */
395
+ bool fPreferHeaders GUARDED_BY (NetEventsInterface::g_msgproc_mutex){false };
396
+
394
397
explicit Peer (NodeId id, ServiceFlags our_services)
395
398
: m_id{id}
396
399
, m_our_services{our_services}
@@ -430,8 +433,6 @@ struct CNodeState {
430
433
int nBlocksInFlight{0 };
431
434
// ! Whether we consider this a preferred download peer.
432
435
bool fPreferredDownload {false };
433
- // ! Whether this peer wants invs or headers (when possible) for block announcements.
434
- bool fPreferHeaders GUARDED_BY (NetEventsInterface::g_msgproc_mutex){false };
435
436
/* * Whether this peer wants invs or cmpctblocks (when possible) for block announcements. */
436
437
bool m_requested_hb_cmpctblocks{false };
437
438
/* * 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,
3447
3448
}
3448
3449
3449
3450
if (msg_type == NetMsgType::SENDHEADERS) {
3450
- LOCK (cs_main);
3451
- State (pfrom.GetId ())->fPreferHeaders = true ;
3451
+ peer->fPreferHeaders = true ;
3452
3452
return ;
3453
3453
}
3454
3454
@@ -5454,7 +5454,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
5454
5454
// add all to the inv queue.
5455
5455
LOCK (peer->m_block_inv_mutex );
5456
5456
std::vector<CBlock> vHeaders;
5457
- bool fRevertToInv = ((!state. fPreferHeaders &&
5457
+ bool fRevertToInv = ((!peer-> fPreferHeaders &&
5458
5458
(!state.m_requested_hb_cmpctblocks || peer->m_blocks_for_headers_relay .size () > 1 )) ||
5459
5459
peer->m_blocks_for_headers_relay .size () > MAX_BLOCKS_TO_ANNOUNCE);
5460
5460
const CBlockIndex *pBestIndex = nullptr ; // last header queued for delivery
@@ -5531,7 +5531,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
5531
5531
m_connman.PushMessage (pto, msgMaker.Make (NetMsgType::CMPCTBLOCK, cmpctblock));
5532
5532
}
5533
5533
state.pindexBestHeaderSent = pBestIndex;
5534
- } else if (state. fPreferHeaders ) {
5534
+ } else if (peer-> fPreferHeaders ) {
5535
5535
if (vHeaders.size () > 1 ) {
5536
5536
LogPrint (BCLog::NET, " %s: %u headers, range (%s, %s), to peer=%d\n " , __func__,
5537
5537
vHeaders.size (),
0 commit comments