mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[net] split PushInventory()
PushInventory() is currently called with a CInv object, which can be a MSG_TX or MSG_BLOCK. PushInventory() only uses the type to determine whether to add the hash to setInventoryTxToSend or vInventoryBlockToSend. Since the caller always knows what type of inventory they're pushing, the CInv is wastefully constructed and thrown away, and tx/block relay is being split out, we split the function into PushTxInventory() and PushBlockInventory().
This commit is contained in:
20
src/net.h
20
src/net.h
@@ -973,19 +973,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void PushInventory(const CInv& inv)
|
||||
void PushTxInventory(const uint256& hash)
|
||||
{
|
||||
if (inv.type == MSG_TX && m_tx_relay != nullptr) {
|
||||
LOCK(m_tx_relay->cs_tx_inventory);
|
||||
if (!m_tx_relay->filterInventoryKnown.contains(inv.hash)) {
|
||||
m_tx_relay->setInventoryTxToSend.insert(inv.hash);
|
||||
}
|
||||
} else if (inv.type == MSG_BLOCK) {
|
||||
LOCK(cs_inventory);
|
||||
vInventoryBlockToSend.push_back(inv.hash);
|
||||
if (m_tx_relay == nullptr) return;
|
||||
LOCK(m_tx_relay->cs_tx_inventory);
|
||||
if (!m_tx_relay->filterInventoryKnown.contains(hash)) {
|
||||
m_tx_relay->setInventoryTxToSend.insert(hash);
|
||||
}
|
||||
}
|
||||
|
||||
void PushBlockInventory(const uint256& hash)
|
||||
{
|
||||
LOCK(cs_inventory);
|
||||
vInventoryBlockToSend.push_back(hash);
|
||||
}
|
||||
|
||||
void PushBlockHash(const uint256 &hash)
|
||||
{
|
||||
LOCK(cs_inventory);
|
||||
|
||||
Reference in New Issue
Block a user