Skip to content

Commit

Permalink
partial/logic backport bitcoin#18544: net: limit BIP37 filter lifespa…
Browse files Browse the repository at this point in the history
…n (active between 'filterload'..'filterclear') (#4043)

* partial backport 18544: net: limit BIP37 filter lifespan (active between 'filterload'..'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.

* net: Match the backport PR a bit more

Co-authored-by: xdustinface <xdustinfacex@gmail.com>
  • Loading branch information
UdjinM6 and xdustinface committed Mar 22, 2021
1 parent ea9daa7 commit bca9577
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/net.cpp
Expand Up @@ -3913,7 +3913,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
nNextAddrSend = 0;
fRelayTxes = false;
fSentAddr = false;
pfilter = MakeUnique<CBloomFilter>();
timeLastMempoolReq = 0;
nLastBlockTime = 0;
nLastTXTime = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Expand Up @@ -900,7 +900,7 @@ class CNode
bool m_masternode_iqr_connection{false};
CSemaphoreGrant grantOutbound;
CCriticalSection cs_filter;
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter);
std::unique_ptr<CBloomFilter> pfilter PT_GUARDED_BY(cs_filter){nullptr};
std::atomic<int> nRefCount;

const uint64_t nKeyedNetGroup;
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Expand Up @@ -3493,7 +3493,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
if (strCommand == NetMsgType::FILTERCLEAR) {
LOCK(pfrom->cs_filter);
if (pfrom->GetLocalServices() & NODE_BLOOM) {
pfrom->pfilter.reset(new CBloomFilter());
pfrom->pfilter = nullptr;
}
pfrom->fRelayTxes = true;
return true;
Expand Down

0 comments on commit bca9577

Please sign in to comment.