@@ -1615,15 +1615,18 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
1615
1615
}
1616
1616
}
1617
1617
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
+ }
1627
1630
}
1628
1631
}
1629
1632
}
@@ -2799,12 +2802,11 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
2799
2802
break ;
2800
2803
}
2801
2804
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 ) {
2804
2806
// When this block is requested, we'll send an inv that'll
2805
2807
// trigger the peer to getblocks the next batch of inventory.
2806
2808
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 ();} );
2808
2810
break ;
2809
2811
}
2810
2812
}
0 commit comments