Net processing: Only call PushAddress() from net_processing #21187

pull jnewbery wants to merge 2 commits into bitcoin:master from jnewbery:2021-02-getpeerlocaladdr changing 4 files +30 −26
  1. jnewbery commented at 12:08 PM on February 15, 2021: member

    This is the first part of #21186. It slightly disentangles addr handling in net/net_processing by making it explicit that net_processing is responsible for pushing addr records into vAddrToSend.

  2. fanquake added the label P2P on Feb 15, 2021
  3. jnewbery renamed this:
    [net processing] Add Peer& arg to MaybeDiscourageAndDisconnect()
    Net processing: only call PushAddress() from net_processing
    on Feb 15, 2021
  4. jnewbery renamed this:
    Net processing: only call PushAddress() from net_processing
    Net processing: Only call PushAddress() from net_processing
    on Feb 15, 2021
  5. jnewbery commented at 1:22 PM on February 16, 2021: member

    Rebased. Moving out of draft status.

  6. jnewbery force-pushed on Feb 16, 2021
  7. jnewbery marked this as ready for review on Feb 16, 2021
  8. DrahtBot commented at 4:02 PM on February 16, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #21186 (Net/Net Processing: Move addr data into net_processing by jnewbery)
    • #20196 (net: fix GetListenPort() to derive the proper port by vasild)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  9. in src/net.cpp:224 in 4ed5aedf28 outdated
     220 | @@ -222,10 +221,12 @@ void AdvertiseLocal(CNode *pnode)
     221 |          }
     222 |          if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
     223 |          {
     224 | -            LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
     225 | -            pnode->PushAddress(addrLocal, rng);
     226 | +            LogPrint(BCLog::NET, "GetPeerLocalAddr: advertising address %s\n", addrLocal.ToString());
    


    sdaftuar commented at 4:43 PM on February 17, 2021:

    Since you're touching this line anyway, you could consider adding the id of the peer that we're sending this to -- it's helpful for tracking which addresses we give to which peers, which is otherwise not obvious from our logging.

    This is unrelated to the goal of this PR so feel free to ignore, too.


    jnewbery commented at 7:48 PM on February 17, 2021:

    Done

  10. in src/net.cpp:204 in 4ed5aedf28 outdated
     200 | @@ -201,8 +201,7 @@ bool IsPeerAddrLocalGood(CNode *pnode)
     201 |             IsReachable(addrLocal.GetNetwork());
     202 |  }
     203 |  
     204 | -// pushes our own address to a peer
     205 | -void AdvertiseLocal(CNode *pnode)
     206 | +Optional<CAddress> GetPeerLocalAddr(CNode *pnode)
    


    sdaftuar commented at 4:48 PM on February 17, 2021:

    nit: perhaps GetLocalAddrForPeer() might be a clearer name? PeerLocalAddr sounds like it could be the peer's address, rather than the address of ours that we think is appropriate for the peer.


    jnewbery commented at 7:48 PM on February 17, 2021:

    Yes, that's better. Changed.

  11. sdaftuar approved
  12. sdaftuar commented at 5:32 PM on February 17, 2021: member

    utACK, just nits.

  13. jnewbery force-pushed on Feb 17, 2021
  14. jnewbery commented at 7:48 PM on February 17, 2021: member

    Thanks for the review @sdaftuar! I've taken both of your suggestions.

  15. sdaftuar commented at 9:08 PM on February 17, 2021: member

    utACK 3c0325e7137f0423c75326b25faa856c5f67b7eb

  16. in src/net.cpp:224 in 9f7d0e42b5 outdated
     220 | @@ -222,10 +221,12 @@ void AdvertiseLocal(CNode *pnode)
     221 |          }
     222 |          if (addrLocal.IsRoutable() || gArgs.GetBoolArg("-addrmantest", false))
     223 |          {
     224 | -            LogPrint(BCLog::NET, "AdvertiseLocal: advertising address %s\n", addrLocal.ToString());
     225 | -            pnode->PushAddress(addrLocal, rng);
     226 | +            LogPrint(BCLog::NET, "GetLocalAddrForPeer: advertising address %s to peer=%d\n", addrLocal.ToString(), pnode->GetId());
    


    MarcoFalke commented at 8:44 AM on February 18, 2021:

    in the first commit: Would be good to remove the function name when touching this. You can use #19809 to get the function name in the log message.


    jnewbery commented at 9:45 AM on February 18, 2021:

    Done

  17. MarcoFalke approved
  18. MarcoFalke commented at 8:54 AM on February 18, 2021: member

    cr ACK 3c0325e7137f0423c75326b25faa856c5f67b7eb 🔼

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    cr ACK 3c0325e7137f0423c75326b25faa856c5f67b7eb 🔼
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUhx2Av/ciCyJfD1yNDR55VEg+5wswy1krjwSeDjeJIlxwwbr5pH5GGB0opCpf7Z
    OMODIQ9/qtqNnerNcqLvAuru+waN4pBOFgV6qkoAfCPjsfwfqwz7BHXmfdbOVD3g
    how3qn2gsEKoxPPz9E1Ei7yJeI9a2sg5fmpaWVI8rWXtLFRvIkT9PC0jRauJyRY9
    EsW+OCKnb0LCcmg+DlVvGx/S9op4vnV2e2LHSPaSoEdSnDZ73HxxDn7Z5mMuwQZV
    fceOyU0JAQKvK7HCL/cKffrCnTNX79KD0uRL6mxPQwssM6N4W4CIYaXosj83KBgt
    FtU3SxjFg4GcVChqLLjWXlZt2iCw3ApheqWRJwsWLJgRvKUL8pmsLsOipDT40r6j
    8dX/BCWWJg+XlJg4vvY7UPHWNZjWW7BW99fDv7ejeUk8tMldyRbX8DQZSCuaSp96
    CsAr0KtRsuvxfJquxH7vIdizUK0aYrXS/MFyhsSPswwWxQXbljViWMDYuYH+5DLh
    LatvFqnM
    =sO8d
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash 11e4333572630de023790d12cb37c30526dcd13d95c1e10af4452856fb74e1a7 -

    </details>

  19. [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.
    d21d2b264c
  20. [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.
    3e68efa615
  21. jnewbery force-pushed on Feb 18, 2021
  22. jnewbery commented at 9:45 AM on February 18, 2021: member

    Thanks for the review @MarcoFalke! I've taken your suggestion.

  23. MarcoFalke approved
  24. MarcoFalke commented at 2:17 PM on February 18, 2021: member

    re-ACK 3e68efa615968e0c9d68a7f197c7852478f6be78 🍅

    <details><summary>Show signature and timestamp</summary>

    Signature:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    re-ACK 3e68efa615968e0c9d68a7f197c7852478f6be78 🍅
    -----BEGIN PGP SIGNATURE-----
    
    iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
    pUiTQAv/UHXsGIiH4mmC9FCK7uV0sMXzxWfaNPXlbzc8HRJ5Q5BxO/hpC+vQSpNN
    Rcg4eWWI+GdpqeX2EXyLCUTckSfQGOtCc+TRztjjYzWIcXojpV/XstKDgqPXj4kk
    hIAa4BH67gYN3XSX5qqCVwtqcxiCAfb7lGi3oQ2wH/qaQXylIe9lPTx8Ijm1iXtD
    iks+MHRcUhzhKbWIGcY+3lxIAZn7QiBLEyR8FQUYqf4tG1oNftMb8lwaml/ti1GC
    IlxB1ast/LIkSNW4boMHX+QnxODoK+hLteY+7qdUQyZ732wlhq75vWIjNoEVRpki
    G7P/1lPZvsQ47iprz0TBtnrSvZbK80uKtpX+IQsVyMku6brNyA7eB7rbeIir9awu
    TXFMt19dR/VwfX+5BadfcmIAso9S4tAGoKLBb86BosaN21TUxqwt+sxcLyFO5bv8
    vw9tItFxMlpbdJ1fOl39qZ/eiaITn6QyJEfoS7S7TNrdrcENbfJQJdW8xfymbnwQ
    cd7wi0jV
    =z/AJ
    -----END PGP SIGNATURE-----
    

    Timestamp of file with hash b508a08160a657b0e132e8bbdb91d64571be968c585f6ca2a374baecd1fb4875 -

    </details>

  25. sdaftuar commented at 5:55 PM on February 18, 2021: member

    re-ACK

  26. MarcoFalke merged this on Feb 19, 2021
  27. MarcoFalke closed this on Feb 19, 2021

  28. jnewbery deleted the branch on Feb 19, 2021
  29. sidhujag referenced this in commit 750732aa95 on Feb 19, 2021
  30. Fabcien referenced this in commit be3a89e814 on Jan 28, 2022
  31. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-30 03:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me