mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
[net] Move checks from GetLocalAddrForPeer to caller
GetLocalAddrForPeer() is only called in one place. The checks inside that function make more sense to be carried out be the caller: - fSuccessfullyConnected is already checked at the top of SendMessages(), so must be true when we call GetLocalAddrForPeer() - fListen can go into the conditional before GetLocalAddrForPeer() is called.
This commit is contained in:
@ -202,8 +202,6 @@ bool IsPeerAddrLocalGood(CNode *pnode)
|
||||
}
|
||||
|
||||
Optional<CAddress> GetLocalAddrForPeer(CNode *pnode)
|
||||
{
|
||||
if (fListen && pnode->fSuccessfullyConnected)
|
||||
{
|
||||
CAddress addrLocal = GetLocalAddress(&pnode->addr, pnode->GetLocalServices());
|
||||
if (gArgs.GetBoolArg("-addrmantest", false)) {
|
||||
@ -224,7 +222,6 @@ Optional<CAddress> GetLocalAddrForPeer(CNode *pnode)
|
||||
LogPrint(BCLog::NET, "Advertising address %s to peer=%d\n", addrLocal.ToString(), pnode->GetId());
|
||||
return addrLocal;
|
||||
}
|
||||
}
|
||||
// Address is unroutable. Don't advertise.
|
||||
return nullopt;
|
||||
}
|
||||
|
@ -4416,7 +4416,9 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
// Address refresh broadcast
|
||||
auto current_time = GetTime<std::chrono::microseconds>();
|
||||
|
||||
if (pto->RelayAddrsWithConn() && !::ChainstateActive().IsInitialBlockDownload() && pto->m_next_local_addr_send < current_time) {
|
||||
if (fListen && pto->RelayAddrsWithConn() &&
|
||||
!::ChainstateActive().IsInitialBlockDownload() &&
|
||||
pto->m_next_local_addr_send < current_time) {
|
||||
// If we've sent before, clear the bloom filter for the peer, so that our
|
||||
// self-announcement will actually go out.
|
||||
// This might be unnecessary if the bloom filter has already rolled
|
||||
|
Reference in New Issue
Block a user