Skip to content

Commit ff6b908

Browse files
[doc] Explain address handling logic in process messages
Co-authored-by: Suhas Daftuar <[email protected]>
1 parent dff16b1 commit ff6b908

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/net_processing.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,22 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
24592459
}
24602460

24612461
if (!pfrom.IsInboundConn() && !pfrom.IsBlockOnlyConn()) {
2462+
// For outbound peers, we try to relay our address (so that other
2463+
// nodes can try to find us more quickly, as we have no guarantee
2464+
// that an outbound peer is even aware of how to reach us) and do a
2465+
// one-time address fetch (to help populate/update our addrman). If
2466+
// we're starting up for the first time, our addrman may be pretty
2467+
// empty and no one will know who we are, so these mechanisms are
2468+
// important to help us connect to the network.
2469+
//
2470+
// We also update the addrman to record connection success for
2471+
// these peers (which include OUTBOUND_FULL_RELAY and FEELER
2472+
// connections) so that addrman will have an up-to-date notion of
2473+
// which peers are online and available.
2474+
//
2475+
// We skip these operations for BLOCK_RELAY peers to avoid
2476+
// potentially leaking information about our BLOCK_RELAY
2477+
// connections via the addrman or address relay.
24622478
if (fListen && !::ChainstateActive().IsInitialBlockDownload())
24632479
{
24642480
CAddress addr = GetLocalAddress(&pfrom.addr, pfrom.GetLocalServices());
@@ -2478,6 +2494,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
24782494
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETADDR));
24792495
pfrom.fGetAddr = true;
24802496

2497+
// Moves address from New to Tried table in Addrman, resolves
2498+
// tried-table collisions, etc.
24812499
m_connman.MarkAddressGood(pfrom.addr);
24822500
}
24832501

0 commit comments

Comments
 (0)