diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2016-04-07 13:57:36 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2016-04-21 00:33:51 +0200 |
commit | dc13dcd2bec2613a1cd5e0395b09b449d176146f (patch) | |
tree | 12b9b2127a823207a201357a5caae98ae167a8d4 /src/net.h | |
parent | f2d3ba73860e875972738d1da1507124d0971ae5 (diff) |
Split up and optimize transaction and block inv queues
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -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); } } |