Replace setInventoryKnown with a rolling bloom filter.
Github-Pull: #7133 Rebased-From:ec73ef37ece20672479e6b849350abb6a0da45dbd41e44c9acaa4b0c26b0
This commit is contained in:
committed by
Wladimir J. van der Laan
parent
6ba25d2886
commit
f31955d9da
19
src/main.cpp
19
src/main.cpp
@@ -4187,8 +4187,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
||||
// however we MUST always provide at least what the remote peer needs
|
||||
typedef std::pair<unsigned int, uint256> PairType;
|
||||
BOOST_FOREACH(PairType& pair, merkleBlock.vMatchedTxn)
|
||||
if (!pfrom->setInventoryKnown.count(CInv(MSG_TX, pair.second)))
|
||||
pfrom->PushMessage("tx", block.vtx[pair.first]);
|
||||
pfrom->PushMessage("tx", block.vtx[pair.first]);
|
||||
}
|
||||
// else
|
||||
// no response
|
||||
@@ -5568,7 +5567,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
vInvWait.reserve(pto->vInventoryToSend.size());
|
||||
BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend)
|
||||
{
|
||||
if (pto->setInventoryKnown.count(inv))
|
||||
if (inv.type == MSG_TX && pto->filterInventoryKnown.contains(inv.hash))
|
||||
continue;
|
||||
|
||||
// trickle out tx inv to protect privacy
|
||||
@@ -5589,15 +5588,13 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||
}
|
||||
}
|
||||
|
||||
// returns true if wasn't already contained in the set
|
||||
if (pto->setInventoryKnown.insert(inv).second)
|
||||
pto->filterInventoryKnown.insert(inv.hash);
|
||||
|
||||
vInv.push_back(inv);
|
||||
if (vInv.size() >= 1000)
|
||||
{
|
||||
vInv.push_back(inv);
|
||||
if (vInv.size() >= 1000)
|
||||
{
|
||||
pto->PushMessage("inv", vInv);
|
||||
vInv.clear();
|
||||
}
|
||||
pto->PushMessage("inv", vInv);
|
||||
vInv.clear();
|
||||
}
|
||||
}
|
||||
pto->vInventoryToSend = vInvWait;
|
||||
|
||||
Reference in New Issue
Block a user