Replace setInventoryKnown with a rolling bloom filter.

Github-Pull: #7133
Rebased-From: ec73ef37ec e20672479e 6b849350ab b6a0da45db d41e44c9ac aa4b0c26b0
This commit is contained in:
Gregory Maxwell
2015-11-26 05:25:30 +00:00
committed by Wladimir J. van der Laan
parent 6ba25d2886
commit f31955d9da
8 changed files with 16 additions and 166 deletions

View File

@@ -9,7 +9,6 @@
#include "bloom.h"
#include "compat.h"
#include "limitedmap.h"
#include "mruset.h"
#include "netbase.h"
#include "protocol.h"
#include "random.h"
@@ -388,7 +387,7 @@ public:
std::set<uint256> setKnown;
// inventory based relay
mruset<CInv> setInventoryKnown;
CRollingBloomFilter filterInventoryKnown;
std::vector<CInv> vInventoryToSend;
CCriticalSection cs_inventory;
std::set<uint256> setAskFor;
@@ -497,7 +496,7 @@ public:
{
{
LOCK(cs_inventory);
setInventoryKnown.insert(inv);
filterInventoryKnown.insert(inv.hash);
}
}
@@ -505,8 +504,9 @@ public:
{
{
LOCK(cs_inventory);
if (!setInventoryKnown.count(inv))
vInventoryToSend.push_back(inv);
if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash))
return;
vInventoryToSend.push_back(inv);
}
}