Skip to content

Commit c51694e

Browse files
committed
Filter mempool command
1 parent e1a4f37 commit c51694e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,13 +3446,16 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
34463446
else if (strCommand == "mempool")
34473447
{
34483448
std::vector<uint256> vtxid;
3449+
LOCK2(mempool.cs, pfrom->cs_filter);
34493450
mempool.queryHashes(vtxid);
34503451
vector<CInv> vInv;
3451-
for (unsigned int i = 0; i < vtxid.size(); i++) {
3452-
CInv inv(MSG_TX, vtxid[i]);
3453-
vInv.push_back(inv);
3454-
if (i == (MAX_INV_SZ - 1))
3455-
break;
3452+
BOOST_FOREACH(uint256& hash, vtxid) {
3453+
CInv inv(MSG_TX, hash);
3454+
if ((pfrom->pfilter && pfrom->pfilter->IsRelevantAndUpdate(mempool.lookup(hash), hash)) ||
3455+
(!pfrom->pfilter))
3456+
vInv.push_back(inv);
3457+
if (vInv.size() == MAX_INV_SZ)
3458+
break;
34563459
}
34573460
if (vInv.size() > 0)
34583461
pfrom->PushMessage("inv", vInv);

0 commit comments

Comments
 (0)