Browse Source

Use unique_ptr for pfilter (CBloomFilter)

0.16
practicalswift 7 years ago
parent
commit
f72cbf9ba9
  1. 4
      src/net.cpp
  2. 2
      src/net.h
  3. 6
      src/net_processing.cpp

4
src/net.cpp

@ -2741,7 +2741,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
nNextInvSend = 0; nNextInvSend = 0;
fRelayTxes = false; fRelayTxes = false;
fSentAddr = false; fSentAddr = false;
pfilter = new CBloomFilter(); pfilter = std::unique_ptr<CBloomFilter>(new CBloomFilter());
timeLastMempoolReq = 0; timeLastMempoolReq = 0;
nLastBlockTime = 0; nLastBlockTime = 0;
nLastTXTime = 0; nLastTXTime = 0;
@ -2771,8 +2771,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
CNode::~CNode() CNode::~CNode()
{ {
CloseSocket(hSocket); CloseSocket(hSocket);
delete pfilter;
} }
void CNode::AskFor(const CInv& inv) void CNode::AskFor(const CInv& inv)

2
src/net.h

@ -648,7 +648,7 @@ public:
bool fSentAddr; bool fSentAddr;
CSemaphoreGrant grantOutbound; CSemaphoreGrant grantOutbound;
CCriticalSection cs_filter; CCriticalSection cs_filter;
CBloomFilter* pfilter; std::unique_ptr<CBloomFilter> pfilter;
std::atomic<int> nRefCount; std::atomic<int> nRefCount;
const uint64_t nKeyedNetGroup; const uint64_t nKeyedNetGroup;

6
src/net_processing.cpp

@ -2755,8 +2755,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
else else
{ {
LOCK(pfrom->cs_filter); LOCK(pfrom->cs_filter);
delete pfrom->pfilter; pfrom->pfilter.reset(new CBloomFilter(filter));
pfrom->pfilter = new CBloomFilter(filter);
pfrom->pfilter->UpdateEmptyFull(); pfrom->pfilter->UpdateEmptyFull();
pfrom->fRelayTxes = true; pfrom->fRelayTxes = true;
} }
@ -2792,8 +2791,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
{ {
LOCK(pfrom->cs_filter); LOCK(pfrom->cs_filter);
if (pfrom->GetLocalServices() & NODE_BLOOM) { if (pfrom->GetLocalServices() & NODE_BLOOM) {
delete pfrom->pfilter; pfrom->pfilter.reset(new CBloomFilter());
pfrom->pfilter = new CBloomFilter();
} }
pfrom->fRelayTxes = true; pfrom->fRelayTxes = true;
} }

Loading…
Cancel
Save