aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2015-11-26 05:25:30 +0000
committerWladimir J. van der Laan <laanwj@gmail.com>2015-12-04 15:01:09 +0100
commitf31955d9da152e5e849575f0297f8fe1904cbfbc (patch)
tree773fb64fc9c15b0000acb9e71ae1fd1c5145f245 /src/main.cpp
parent6ba25d28868146d5d6dbd671881db3a58f549567 (diff)
downloadbitcoin-f31955d9da152e5e849575f0297f8fe1904cbfbc.tar.xz
Replace setInventoryKnown with a rolling bloom filter.
Github-Pull: #7133 Rebased-From: ec73ef37eccfeda76de55c4ff93ea54d4e69e1ec e20672479ef7f2048c2e27494397641d47a4d88d 6b849350ab074a7ccb80ecbef387f59e1271ded6 b6a0da45db8d534e7a77d1cebe382cd5d83ba9b8 d41e44c9accb3df84e0abbc602cc76b72754d382 aa4b0c26b0a94ca6164c441aae723e118554d214
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b200109a6a..f7b9d073ed 100644
--- a/src/main.cpp
+++ b/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;