aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-07-09 07:42:11 +0100
committerJohn Newbery <john@johnnewbery.com>2021-02-18 09:28:06 +0000
commitd21d2b264cd77c027a06f68289cf4c3f177d1ed0 (patch)
tree8af47d2c169f527e619efae3c9c979874e3a486e /src/net.cpp
parent9bbf08bf98487eeb75f143c120cfd544ea3135fb (diff)
downloadbitcoin-d21d2b264cd77c027a06f68289cf4c3f177d1ed0.tar.xz
[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.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 81176785a2..bd89df63bf 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -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