Skip to content

Commit 5eae034

Browse files
committed
net: limit BIP37 filter lifespan (active between 'filterload' and 'filterclear')
Previously, a default match-everything bloom filter was set for every peer, i.e. even before receiving a 'filterload' message and after receiving a 'filterclear' message code branches checking for the existence of the filter by testing the pointer "pfilter" were _always_ executed.
1 parent 661bd5d commit 5eae034

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/net.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,14 +809,13 @@ class CNode
809809
RecursiveMutex cs_inventory;
810810

811811
struct TxRelay {
812-
TxRelay() { pfilter = MakeUnique<CBloomFilter>(); }
813812
mutable RecursiveMutex cs_filter;
814813
// We use fRelayTxes for two purposes -
815814
// a) it allows us to not relay tx invs before receiving the peer's version message
816815
// b) the peer may tell us in its version message that we should not relay tx invs
817816
// unless it loads a bloom filter.
818817
bool fRelayTxes GUARDED_BY(cs_filter){false};
819-
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter) GUARDED_BY(cs_filter);
818+
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter) GUARDED_BY(cs_filter){nullptr};
820819

821820
mutable RecursiveMutex cs_tx_inventory;
822821
CRollingBloomFilter filterInventoryKnown GUARDED_BY(cs_tx_inventory){50000, 0.000001};

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3198,7 +3198,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRec
31983198
}
31993199
LOCK(pfrom->m_tx_relay->cs_filter);
32003200
if (pfrom->GetLocalServices() & NODE_BLOOM) {
3201-
pfrom->m_tx_relay->pfilter.reset(new CBloomFilter());
3201+
pfrom->m_tx_relay->pfilter = nullptr;
32023202
}
32033203
pfrom->m_tx_relay->fRelayTxes = true;
32043204
return true;

0 commit comments

Comments
 (0)