Skip to content

Commit 99f6768

Browse files
committed
[net] Don't PushAddress(self) on VERSION
Previously, we would prepare to self-announce to a new peer while parsing a VERSION message from that peer. This is useless, because we do something very similar in AdvertiseLocal(), although there are a couple differences: 1) AdvertiseLocal() does this for all peers, not just outbound 2) AdvertiseLocal() always asks the peer to advertise based on what they think we are AND what we think we are (assuming it's routable), while PushAddress(self) on VERSION always does one of the two. (1) and the fact that AdvertiseLocal() is called right before actually sending out ADDR message with our address makes it fully encompassing PushAddress(self) on VERSION. Per (2), AdvertiseLocal() seems like a better version of PushAddress(self) on VERSION. Thus, it's fine to drop PushAddress(self) on VERSION.
1 parent 10fc62f commit 99f6768

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2386,32 +2386,14 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
23862386
}
23872387

23882388
if (!pfrom.IsInboundConn() && !pfrom.IsBlockOnlyConn()) {
2389-
// For outbound peers, we try to relay our address (so that other
2390-
// nodes can try to find us more quickly, as we have no guarantee
2391-
// that an outbound peer is even aware of how to reach us) and do a
2392-
// one-time address fetch (to help populate/update our addrman). If
2393-
// we're starting up for the first time, our addrman may be pretty
2394-
// empty and no one will know who we are, so these mechanisms are
2389+
// For outbound peers, we do a one-time address fetch
2390+
// (to help populate/update our addrman).
2391+
// If we're starting up for the first time, our addrman may be pretty
2392+
// empty and no one will know who we are, so this mechanism is
23952393
// important to help us connect to the network.
23962394
//
23972395
// We skip this for block-relay-only peers to avoid potentially leaking
23982396
// information about our block-relay-only connections via address relay.
2399-
if (fListen && !::ChainstateActive().IsInitialBlockDownload() && pfrom.fSuccessfullyConnected)
2400-
{
2401-
CAddress addr = GetLocalAddress(pfrom.addr, pfrom.GetLocalServices());
2402-
FastRandomContext insecure_rand;
2403-
if (addr.IsRoutable())
2404-
{
2405-
LogPrint(BCLog::NET, "ProcessMessages: advertising address %s\n", addr.ToString());
2406-
pfrom.PushAddress(addr, insecure_rand);
2407-
} else if (IsPeerAddrLocalGood(pfrom)) {
2408-
addr.SetIP(addrMe);
2409-
LogPrint(BCLog::NET, "ProcessMessages: advertising address %s\n", addr.ToString());
2410-
pfrom.PushAddress(addr, insecure_rand);
2411-
}
2412-
}
2413-
2414-
// Get recent addresses
24152397
m_connman.PushMessage(&pfrom, CNetMsgMaker(greatest_common_version).Make(NetMsgType::GETADDR));
24162398
pfrom.fGetAddr = true;
24172399
}

0 commit comments

Comments
 (0)