mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
[net] Change AdvertiseLocal to GetLocalAddrForPeer
Gossiping addresses to peers is the responsibility of net processing. Change AdvertiseLocal() in net to just return an (optional) address for net processing to advertise. Update function name to reflect new responsibility.
This commit is contained in:
@@ -201,8 +201,7 @@ bool IsPeerAddrLocalGood(CNode *pnode)
|
||||
IsReachable(addrLocal.GetNetwork());
|
||||
}
|
||||
|
||||
// pushes our own address to a peer
|
||||
void AdvertiseLocal(CNode *pnode)
|
||||
Optional<CAddress> GetLocalAddrForPeer(CNode *pnode)
|
||||
{
|
||||
if (fListen && pnode->fSuccessfullyConnected)
|
||||
{
|
||||
@@ -222,10 +221,12 @@ void AdvertiseLocal(CNode *pnode)
|
||||
}
|
||||
if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
|
||||
{
|
||||
LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
|
||||
pnode->PushAddress(addrLocal, rng);
|
||||
LogPrint(BCLog::NET, "Advertising address %s to peer=%d\n", addrLocal.ToString(), pnode->GetId());
|
||||
return addrLocal;
|
||||
}
|
||||
}
|
||||
// Address is unroutable. Don't advertise.
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
// learn a new local address
|
||||
|
||||
Reference in New Issue
Block a user