Avoid advertising the node's address when it is not listening or IsInitialBlockDownload().
This also avoids flushing setAddrKnown until 24 hours has passed, and avoids contacting the external IP services when not listening. Advertising non-listening nodes is just addr message spam. It doesn't help the network, in fact it hurts the network, and it also hurts user's privacy. Advertising far out of sync nodes doesn't help the network— they can't even forward (most) transactions and wastes nodes outbound slots.
This commit is contained in:
parent
d2291cce92
commit
5d1b8f1725
2 changed files with 8 additions and 6 deletions
12
src/main.cpp
12
src/main.cpp
|
@ -2107,7 +2107,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
if (!pfrom->fInbound)
|
||||
{
|
||||
// Advertise our address
|
||||
if (addrLocalHost.IsRoutable() && !fUseProxy)
|
||||
if (!fNoListen && !fUseProxy && addrLocalHost.IsRoutable() &&
|
||||
!IsInitialBlockDownload())
|
||||
{
|
||||
CAddress addr(addrLocalHost);
|
||||
addr.nTime = GetAdjustedTime();
|
||||
|
@ -2703,18 +2704,18 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||
|
||||
// Address refresh broadcast
|
||||
static int64 nLastRebroadcast;
|
||||
if (GetTime() - nLastRebroadcast > 24 * 60 * 60)
|
||||
if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
|
||||
{
|
||||
nLastRebroadcast = GetTime();
|
||||
CRITICAL_BLOCK(cs_vNodes)
|
||||
{
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
{
|
||||
// Periodically clear setAddrKnown to allow refresh broadcasts
|
||||
pnode->setAddrKnown.clear();
|
||||
if (nLastRebroadcast)
|
||||
pnode->setAddrKnown.clear();
|
||||
|
||||
// Rebroadcast our address
|
||||
if (addrLocalHost.IsRoutable() && !fUseProxy)
|
||||
if (!fNoListen && !fUseProxy && addrLocalHost.IsRoutable())
|
||||
{
|
||||
CAddress addr(addrLocalHost);
|
||||
addr.nTime = GetAdjustedTime();
|
||||
|
@ -2722,6 +2723,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||
}
|
||||
}
|
||||
}
|
||||
nLastRebroadcast = GetTime();
|
||||
}
|
||||
|
||||
// Clear out old addresses periodically so it's not too much work at once
|
||||
|
|
|
@ -141,7 +141,7 @@ bool GetMyExternalIP(CNetAddr& ipRet)
|
|||
const char* pszGet;
|
||||
const char* pszKeyword;
|
||||
|
||||
if (fUseProxy)
|
||||
if (fNoListen||fUseProxy)
|
||||
return false;
|
||||
|
||||
for (int nLookup = 0; nLookup <= 1; nLookup++)
|
||||
|
|
Loading…
Reference in a new issue