Ensure CNode::addrKnown immediately takes little memory when we disconnect the node

This commit is contained in:
Duke
2023-03-17 00:21:00 -04:00
parent c1baab7b8a
commit 63ad87f69b
3 changed files with 29 additions and 9 deletions

View File

@@ -7132,7 +7132,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
addr.nTime = nNow - 5 * 24 * 60 * 60;
pfrom->AddAddressKnown(addr);
pfrom->AddAddressIfNotAlreadyKnown(addr);
++num_proc;
bool fReachable = IsReachable(addr);
if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable())
@@ -7988,9 +7989,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
vAddr.reserve(pto->vAddrToSend.size());
BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend)
{
if (!pto->addrKnown.contains(addr.GetKey()))
if (pto->AddAddressIfNotAlreadyKnown(addr))
{
pto->addrKnown.insert(addr.GetKey());
vAddr.push_back(addr);
if (vAddr.size() >= MAX_ADDR_TO_SEND)