aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2016-04-07 13:57:36 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2016-04-21 00:33:51 +0200
commitdc13dcd2bec2613a1cd5e0395b09b449d176146f (patch)
tree12b9b2127a823207a201357a5caae98ae167a8d4 /src/net.h
parentf2d3ba73860e875972738d1da1507124d0971ae5 (diff)
Split up and optimize transaction and block inv queues
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/net.h b/src/net.h
index bf367684f6..a95fa79e7e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -397,7 +397,13 @@ public:
// inventory based relay
CRollingBloomFilter filterInventoryKnown;
- std::vector<CInv> vInventoryToSend;
+ // Set of transaction ids we still have to announce.
+ // They are sorted by the mempool before relay, so the order is not important.
+ std::set<uint256> setInventoryTxToSend;
+ // List of block ids we still have announce.
+ // There is no final sorting before sending, as they are always sent immediately
+ // and in the order requested.
+ std::vector<uint256> vInventoryBlockToSend;
CCriticalSection cs_inventory;
std::set<uint256> setAskFor;
std::multimap<int64_t, CInv> mapAskFor;
@@ -517,11 +523,13 @@ public:
void PushInventory(const CInv& inv)
{
- {
- LOCK(cs_inventory);
- if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash))
- return;
- vInventoryToSend.push_back(inv);
+ LOCK(cs_inventory);
+ if (inv.type == MSG_TX) {
+ if (!filterInventoryKnown.contains(inv.hash)) {
+ setInventoryTxToSend.insert(inv.hash);
+ }
+ } else if (inv.type == MSG_BLOCK) {
+ vInventoryBlockToSend.push_back(inv.hash);
}
}