Skip to content

Commit

Permalink
Honor filterInventoryKnown for non-tx/non-block items (#2292)
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock authored and UdjinM6 committed Sep 14, 2018
1 parent 6adc236 commit 9d90b4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,15 @@ class CNode


void AddInventoryKnown(const CInv& inv)
{
AddInventoryKnown(inv.hash);
}

void AddInventoryKnown(const uint256& hash)
{
{
LOCK(cs_inventory);
filterInventoryKnown.insert(inv.hash);
filterInventoryKnown.insert(hash);
}
}

Expand All @@ -908,8 +913,12 @@ class CNode
LogPrint("net", "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
vInventoryBlockToSend.push_back(inv.hash);
} else {
LogPrint("net", "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
vInventoryOtherToSend.push_back(inv);
if (!filterInventoryKnown.contains(inv.hash)) {
LogPrint("net", "PushInventory -- inv: %s peer=%d\n", inv.ToString(), id);
vInventoryOtherToSend.push_back(inv);
} else {
LogPrint("net", "PushInventory -- filtered inv: %s peer=%d\n", inv.ToString(), id);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,11 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr

// Send non-tx/non-block inventory items
for (const auto& inv : pto->vInventoryOtherToSend) {
if (pto->filterInventoryKnown.contains(inv.hash)) {
continue;
}
vInv.push_back(inv);
pto->filterInventoryKnown.insert(inv.hash);
if (vInv.size() == MAX_INV_SZ) {
connman.PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));
vInv.clear();
Expand Down

0 comments on commit 9d90b4f

Please sign in to comment.