mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-06 13:10:09 +02:00
[net processing] Guard m_continuation_block with m_block_inv_mutex
This commit is contained in:
parent
184557e8e0
commit
3002b4af2b
@ -1615,15 +1615,18 @@ void static ProcessGetBlockData(CNode& pfrom, Peer& peer, const CChainParams& ch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger the peer node to send a getblocks request for the next batch of inventory
|
{
|
||||||
if (inv.hash == peer.m_continuation_block) {
|
LOCK(peer.m_block_inv_mutex);
|
||||||
// Send immediately. This must send even if redundant,
|
// Trigger the peer node to send a getblocks request for the next batch of inventory
|
||||||
// and we want it right after the last block so they don't
|
if (inv.hash == peer.m_continuation_block) {
|
||||||
// wait for other stuff first.
|
// Send immediately. This must send even if redundant,
|
||||||
std::vector<CInv> vInv;
|
// and we want it right after the last block so they don't
|
||||||
vInv.push_back(CInv(MSG_BLOCK, ::ChainActive().Tip()->GetBlockHash()));
|
// wait for other stuff first.
|
||||||
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv));
|
std::vector<CInv> vInv;
|
||||||
peer.m_continuation_block.SetNull();
|
vInv.push_back(CInv(MSG_BLOCK, ::ChainActive().Tip()->GetBlockHash()));
|
||||||
|
connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::INV, vInv));
|
||||||
|
peer.m_continuation_block.SetNull();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2799,12 +2802,11 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
WITH_LOCK(peer->m_block_inv_mutex, peer->m_blocks_for_inv_relay.push_back(pindex->GetBlockHash()));
|
WITH_LOCK(peer->m_block_inv_mutex, peer->m_blocks_for_inv_relay.push_back(pindex->GetBlockHash()));
|
||||||
if (--nLimit <= 0)
|
if (--nLimit <= 0) {
|
||||||
{
|
|
||||||
// When this block is requested, we'll send an inv that'll
|
// When this block is requested, we'll send an inv that'll
|
||||||
// trigger the peer to getblocks the next batch of inventory.
|
// trigger the peer to getblocks the next batch of inventory.
|
||||||
LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
LogPrint(BCLog::NET, " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
peer->m_continuation_block = pindex->GetBlockHash();
|
WITH_LOCK(peer->m_block_inv_mutex, {peer->m_continuation_block = pindex->GetBlockHash();});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,14 +73,14 @@ struct Peer {
|
|||||||
* message. If we can't announce via a `headers` message, we'll fall back to
|
* message. If we can't announce via a `headers` message, we'll fall back to
|
||||||
* announcing via `inv`. */
|
* announcing via `inv`. */
|
||||||
std::vector<uint256> m_blocks_for_headers_relay GUARDED_BY(m_block_inv_mutex);
|
std::vector<uint256> m_blocks_for_headers_relay GUARDED_BY(m_block_inv_mutex);
|
||||||
|
|
||||||
/** This peer's reported block height when we connected */
|
|
||||||
std::atomic<int> m_starting_height{-1};
|
|
||||||
/** The final block hash that we sent in an `inv` message to this peer.
|
/** The final block hash that we sent in an `inv` message to this peer.
|
||||||
* When the peer requests this block, we send an `inv` message to trigger
|
* When the peer requests this block, we send an `inv` message to trigger
|
||||||
* the peer to request the next sequence of block hashes.
|
* the peer to request the next sequence of block hashes.
|
||||||
* Most peers use headers-first syncing, which doesn't use this mechanism */
|
* Most peers use headers-first syncing, which doesn't use this mechanism */
|
||||||
uint256 m_continuation_block{};
|
uint256 m_continuation_block GUARDED_BY(m_block_inv_mutex) {};
|
||||||
|
|
||||||
|
/** This peer's reported block height when we connected */
|
||||||
|
std::atomic<int> m_starting_height{-1};
|
||||||
|
|
||||||
/** Set of txids to reconsider once their parent transactions have been accepted **/
|
/** Set of txids to reconsider once their parent transactions have been accepted **/
|
||||||
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
|
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user