aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-06-18 15:19:12 -0400
committerJohn Newbery <john@johnnewbery.com>2020-06-18 15:45:48 -0400
commitf52d403b81e758e9bc33847560b5740b22d95fff (patch)
tree3b66bcbf2f9739fe582a98e3c7498d1f2d55221f /src/net.h
parentc2bcb99c1d113ac090914e87b6f5676b5b55f82e (diff)
downloadbitcoin-f52d403b81e758e9bc33847560b5740b22d95fff.tar.xz
[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().
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/net.h b/src/net.h
index 517445e8f4..9c3a95130c 100644
--- a/src/net.h
+++ b/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);