aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2020-09-02 14:03:43 -0700
committerAmiti Uttarwar <amiti@uttarwar.org>2020-09-02 17:18:21 -0700
commitff6b9081add3a40d53b1cc1352b57eeb46e41d45 (patch)
treed1b69fec09c043140696cece772794c2f6964615
parentdff16b184b1428a068d144e5e4dde7595b4729c0 (diff)
downloadbitcoin-ff6b9081add3a40d53b1cc1352b57eeb46e41d45.tar.xz
[doc] Explain address handling logic in process messages
Co-authored-by: Suhas Daftuar <sdaftuar@gmail.com>
-rw-r--r--src/net_processing.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 4da818c996..dae77dabfb 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2459,6 +2459,22 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
}
if (!pfrom.IsInboundConn() && !pfrom.IsBlockOnlyConn()) {
+ // For outbound peers, we try to relay our address (so that other
+ // nodes can try to find us more quickly, as we have no guarantee
+ // that an outbound peer is even aware of how to reach us) and do a
+ // one-time address fetch (to help populate/update our addrman). If
+ // we're starting up for the first time, our addrman may be pretty
+ // empty and no one will know who we are, so these mechanisms are
+ // important to help us connect to the network.
+ //
+ // We also update the addrman to record connection success for
+ // these peers (which include OUTBOUND_FULL_RELAY and FEELER
+ // connections) so that addrman will have an up-to-date notion of
+ // which peers are online and available.
+ //
+ // We skip these operations for BLOCK_RELAY peers to avoid
+ // potentially leaking information about our BLOCK_RELAY
+ // connections via the addrman or address relay.
if (fListen && !::ChainstateActive().IsInitialBlockDownload())
{
CAddress addr = GetLocalAddress(&pfrom.addr, pfrom.GetLocalServices());
@@ -2478,6 +2494,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
m_connman.PushMessage(&pfrom, CNetMsgMaker(nSendVersion).Make(NetMsgType::GETADDR));
pfrom.fGetAddr = true;
+ // Moves address from New to Tried table in Addrman, resolves
+ // tried-table collisions, etc.
m_connman.MarkAddressGood(pfrom.addr);
}