mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Optimize vInv.reserve in SendMessages
1. Don't call it while holding cs_invetory 2. Also take setInventoryTxToSend.size() into account
This commit is contained in:
parent
027a852a77
commit
201f8eea1a
@ -3812,8 +3812,12 @@ bool PeerLogicValidation::SendMessages(CNode* pto, std::atomic<bool>& interruptM
|
||||
//
|
||||
std::vector<CInv> vInv;
|
||||
{
|
||||
size_t reserve = std::min<size_t>(pto->setInventoryTxToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize(true) / 1000000);
|
||||
reserve = std::max<size_t>(reserve, pto->vInventoryBlockToSend.size());
|
||||
reserve = std::min<size_t>(reserve, MAX_INV_SZ);
|
||||
vInv.reserve(reserve);
|
||||
|
||||
LOCK(pto->cs_inventory);
|
||||
vInv.reserve(std::max<size_t>(pto->vInventoryBlockToSend.size(), INVENTORY_BROADCAST_MAX_PER_1MB_BLOCK * MaxBlockSize(true) / 1000000));
|
||||
|
||||
// Add blocks
|
||||
for (const uint256& hash : pto->vInventoryBlockToSend) {
|
||||
|
Loading…
Reference in New Issue
Block a user