@@ -1615,15 +1615,18 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
16151615 }
16161616 }
16171617
1618- // Trigger the peer node to send a getblocks request for the next batch of inventory
1619- if (inv.hash == peer.m_continuation_block ) {
1620- // Send immediately. This must send even if redundant,
1621- // and we want it right after the last block so they don't
1622- // wait for other stuff first.
1623- std::vector<CInv> vInv;
1624- vInv.push_back (CInv (MSG_BLOCK, ::ChainActive ().Tip ()->GetBlockHash ()));
1625- connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::INV, vInv));
1626- peer.m_continuation_block .SetNull ();
1618+ {
1619+ LOCK (peer.m_block_inv_mutex );
1620+ // Trigger the peer node to send a getblocks request for the next batch of inventory
1621+ if (inv.hash == peer.m_continuation_block ) {
1622+ // Send immediately. This must send even if redundant,
1623+ // and we want it right after the last block so they don't
1624+ // wait for other stuff first.
1625+ std::vector<CInv> vInv;
1626+ vInv.push_back (CInv (MSG_BLOCK, ::ChainActive ().Tip ()->GetBlockHash ()));
1627+ connman.PushMessage (&pfrom, msgMaker.Make (NetMsgType::INV, vInv));
1628+ peer.m_continuation_block .SetNull ();
1629+ }
16271630 }
16281631 }
16291632}
@@ -2799,12 +2802,11 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
27992802 break ;
28002803 }
28012804 WITH_LOCK (peer->m_block_inv_mutex , peer->m_blocks_for_inv_relay .push_back (pindex->GetBlockHash ()));
2802- if (--nLimit <= 0 )
2803- {
2805+ if (--nLimit <= 0 ) {
28042806 // When this block is requested, we'll send an inv that'll
28052807 // trigger the peer to getblocks the next batch of inventory.
28062808 LogPrint (BCLog::NET, " getblocks stopping at limit %d %s\n " , pindex->nHeight , pindex->GetBlockHash ().ToString ());
2807- peer->m_continuation_block = pindex->GetBlockHash ();
2809+ WITH_LOCK ( peer->m_block_inv_mutex , {peer-> m_continuation_block = pindex->GetBlockHash ();} );
28082810 break ;
28092811 }
28102812 }
0 commit comments