p2p: Avoid allocating memory for addrKnown where we don't need it

This commit is contained in:
User
2019-10-16 17:06:20 -04:00
parent c34b88620d
commit 090b75c14b
4 changed files with 10 additions and 10 deletions

View File

@@ -729,7 +729,7 @@ public:
// flood relay
std::vector<CAddress> vAddrToSend;
CRollingBloomFilter addrKnown;
std::unique_ptr<CRollingBloomFilter> m_addr_known;
bool fGetAddr{false};
int64_t nNextAddrSend GUARDED_BY(cs_sendProcessing){0};
int64_t nNextLocalAddrSend GUARDED_BY(cs_sendProcessing){0};
@@ -884,7 +884,7 @@ public:
void AddAddressKnown(const CAddress& _addr)
{
addrKnown.insert(_addr.GetKey());
m_addr_known->insert(_addr.GetKey());
}
void PushAddress(const CAddress& _addr, FastRandomContext &insecure_rand)
@@ -892,7 +892,7 @@ public:
// Known checking here is only to save space from duplicates.
// SendMessages will filter it again for knowns that were added
// after addresses were pushed.
if (_addr.IsValid() && !addrKnown.contains(_addr.GetKey())) {
if (_addr.IsValid() && !m_addr_known->contains(_addr.GetKey())) {
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
vAddrToSend[insecure_rand.randrange(vAddrToSend.size())] = _addr;
} else {