From e2d2d58f9a4307011f69daeea8294bc8e30626cc Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 14 Sep 2018 14:19:21 +0200 Subject: [PATCH] Honor filterInventoryKnown for non-tx/non-block items --- src/net.h | 15 ++++++++++++--- src/net_processing.cpp | 4 ++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/net.h b/src/net.h index afbbc028796e..03ef7069c181 100644 --- a/src/net.h +++ b/src/net.h @@ -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); } } @@ -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); + } } } diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 1a32aa25236a..b71c76d35a78 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3431,7 +3431,11 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic& 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();