|
|
|
@ -319,6 +319,26 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
@@ -319,6 +319,26 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
|
|
|
|
|
int nId; |
|
|
|
|
CAddrInfo *pinfo = Find(addr, &nId); |
|
|
|
|
|
|
|
|
|
// port changed to random with twisterd >= 0.9.30
|
|
|
|
|
// we must replace old port info with the newer one
|
|
|
|
|
if( pinfo && pinfo->GetPort() != addr.GetPort() && |
|
|
|
|
pinfo->GetPort() == Params().GetDefaultPort() ) { |
|
|
|
|
// remove the entry from all new buckets
|
|
|
|
|
for (std::vector<std::set<int> >::iterator it = vvNew.begin(); it != vvNew.end(); it++) |
|
|
|
|
{ |
|
|
|
|
if ((*it).erase(nId)) |
|
|
|
|
pinfo->nRefCount--; |
|
|
|
|
} |
|
|
|
|
if (pinfo->nRefCount == 0) |
|
|
|
|
{ |
|
|
|
|
SwapRandom(pinfo->nRandomPos, vRandom.size()-1); |
|
|
|
|
vRandom.pop_back(); |
|
|
|
|
mapAddr.erase(*pinfo); |
|
|
|
|
mapInfo.erase(nId); |
|
|
|
|
pinfo = NULL; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pinfo) |
|
|
|
|
{ |
|
|
|
|
// periodically update nTime
|
|
|
|
|