docs: Improve netaddress comments #15718

pull dongcarl wants to merge 1 commits into bitcoin:master from dongcarl:2019-04-netaddr-comments changing 2 files +119 −10
  1. dongcarl commented at 7:31 PM on April 1, 2019: member

    Improves comments for netaddress, making them available to Doxygen.

    I think this is worthwhile because a lot of the code require some context (e.g., A lot of the things that we do to fit hostnames and tor addresses into CNetAddr is non-obvious, and documenting it is beneficial).

  2. dongcarl added the label Docs on Apr 1, 2019
  3. fanquake added the label P2P on Apr 1, 2019
  4. DrahtBot commented at 10:01 PM on April 1, 2019: 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:

    • #15689 (netaddress: Update CNetAddr for ORCHIDv2 by dongcarl)

    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.

  5. dongcarl force-pushed on Apr 2, 2019
  6. dongcarl marked this as ready for review on Apr 2, 2019
  7. dongcarl renamed this:
    [WIP] docs: Improve netaddress comments
    docs: Improve netaddress comments
    on Apr 2, 2019
  8. dongcarl commented at 3:45 PM on April 2, 2019: member

    This is now ready for review.

  9. in src/netaddress.cpp:233 in b11dbf729f outdated
     223 | @@ -194,6 +224,10 @@ bool CNetAddr::IsLocal() const
     224 |      return false;
     225 |  }
     226 |  
     227 | +/**
     228 | + * @returns Whether or not this network address is a valid address that @a could
    


    practicalswift commented at 5:33 PM on April 2, 2019:

    @a a typo? :-)


    dongcarl commented at 5:37 PM on April 2, 2019:

    Nope, it italicizes I believe.

  10. practicalswift commented at 5:36 PM on April 2, 2019: contributor

    Concept ACK -- nice clarification! Will review.

    A minor nit: make sure "IPv4", "IPv6" or "IP" are capitalised consistently. Some cases of "ip" in the current version.

  11. dongcarl force-pushed on Apr 2, 2019
  12. dongcarl commented at 5:56 PM on April 2, 2019: member

    Fixed some wording and changed some cases of "ip" to "address."

  13. in src/netaddress.cpp:51 in 7d3ee5cf80 outdated
      46 | + * addresses have a prefix of fd6b:88c0:8724::/48 and are guaranteed to not be
      47 | + * publicly routable as it falls under RFC4193's fc00::/7 subnet allocated to
      48 | + * unique-local addresses.
      49 | + *
      50 | + * This is useful for having some source address to identify the hostname of DNS
      51 | + * seeds with in CAddrMan without doing a resolve.
    


    jonatack commented at 11:09 AM on April 4, 2019:

    Nit: "with in" -> "within" ?


    dongcarl commented at 2:58 PM on April 4, 2019:

    Yeah this is confusing, will reword.

  14. in src/netaddress.cpp:71 in 7d3ee5cf80 outdated
      65 | @@ -52,6 +66,16 @@ bool CNetAddr::SetInternal(const std::string &name)
      66 |      return true;
      67 |  }
      68 |  
      69 | +/**
      70 | + * Try to make this a dummy address that maps the specified onion address into
      71 | + * IPv6 using OnionCat's range and encoding. Such dummy addresses has a prefix
    


    jonatack commented at 11:10 AM on April 4, 2019:

    Nit: "has" -> "have".

  15. in src/netaddress.cpp:72 in 7d3ee5cf80 outdated
      65 | @@ -52,6 +66,16 @@ bool CNetAddr::SetInternal(const std::string &name)
      66 |      return true;
      67 |  }
      68 |  
      69 | +/**
      70 | + * Try to make this a dummy address that maps the specified onion address into
      71 | + * IPv6 using OnionCat's range and encoding. Such dummy addresses has a prefix
      72 | + * of fd87:d87e:eb43::/48 and is guaranteed to not be publicly routable as it
    


    jonatack commented at 11:11 AM on April 4, 2019:

    Nit: "is" -> "are" and "it" -> "they".

  16. in src/netaddress.cpp:73 in 7d3ee5cf80 outdated
      65 | @@ -52,6 +66,16 @@ bool CNetAddr::SetInternal(const std::string &name)
      66 |      return true;
      67 |  }
      68 |  
      69 | +/**
      70 | + * Try to make this a dummy address that maps the specified onion address into
      71 | + * IPv6 using OnionCat's range and encoding. Such dummy addresses has a prefix
      72 | + * of fd87:d87e:eb43::/48 and is guaranteed to not be publicly routable as it
      73 | + * falls under RFC4193's fc00::/7 subnet allocated to unique-local addresses.
    


    jonatack commented at 11:11 AM on April 4, 2019:

    Nit: "falls" -> "fall".

  17. dongcarl force-pushed on Apr 4, 2019
  18. dongcarl commented at 5:12 PM on April 4, 2019: member

    Addressed nits from @jonatack

  19. in src/netaddress.cpp:50 in ef22bf11b7 outdated
      45 | + * so: (0xFD + %sha256("bitcoin")[0:5]) + %sha256(name)[0:10]. Such dummy
      46 | + * addresses have a prefix of fd6b:88c0:8724::/48 and are guaranteed to not be
      47 | + * publicly routable as it falls under RFC4193's fc00::/7 subnet allocated to
      48 | + * unique-local addresses.
      49 | + *
      50 | + * CAddrMan can use this as a source address to identify DNS seed hostnames.
    


    ryanofsky commented at 5:22 PM on April 5, 2019:

    In commit "docs: netaddress: Improve {Is,Set}Internal docs" (ef22bf11b71a5b5e396fd15de5c9db979c9fe501)

    While it's seems helpful to mention CAddrMan, the new comment seems less clear than the original "Useful for mapping resolved addresses back to their source". Would maybe suggest: "CAddrMan uses these fake addresses to keep track of which DNS seeds were used."

    The next sentence about extra resolves doesn't also make sense to me, and I'd probably suggest dropping it. I'd expect if this method were not available, the obvious alternative for CAddrMan would be to track strings in addition to addresses, not to start doing extra resolves.

  20. in src/netaddress.cpp:234 in 2473fef57e outdated
     224 | @@ -225,6 +225,10 @@ bool CNetAddr::IsLocal() const
     225 |      return false;
     226 |  }
     227 |  
     228 | +/**
     229 | + * @returns Whether or not this network address is a valid address that @a could
     230 | + *          be used to refer to an actual host.
    


    ryanofsky commented at 5:28 PM on April 5, 2019:

    In commit "docs: netaddress: Add IsValid docs" (2473fef57e54aaa2513cb0ff90ccfce3138fc66a)

    Can the comment say how this is different than IsRoutable, or related to it?

  21. in src/netaddress.cpp:386 in 862a5579d9 outdated
     379 | @@ -380,8 +380,16 @@ bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const
     380 |      return true;
     381 |  }
     382 |  
     383 | -// get canonical identifier of an address' group
     384 | -// no two connections will be attempted to addresses with the same group
     385 | +/**
     386 | + * Get the canonical identifier of our network group
     387 | + *
     388 | + * Networks groups aim to group addresses by the (approximate) cost to obtain
    


    ryanofsky commented at 6:58 PM on April 5, 2019:

    In commit "docs: netaddress: Improve GetGroup docs" (862a5579d99e95bb159f4dfdca2d525ff239337d)

    I think a more direct way of saying this would be: "The groups are assigned in a way where it should be costly for an attacker to obtain addresses with many different group identifiers, even if it is cheap to obtain addresses with the same identifier."

    The way it's written now it sounds like this is trying to divide addresses up by how much the addresses cost (like expensive addresses grouped with expensive addresses, cheap ones grouped with cheap ones).

  22. in src/netaddress.cpp:654 in b3697888fc outdated
     651 |       std::vector<unsigned char> vKey;
     652 |       vKey.resize(18);
     653 |       memcpy(vKey.data(), ip, 16);
     654 | -     vKey[16] = port / 0x100;
     655 | -     vKey[17] = port & 0x0FF;
     656 | +     vKey[16] = port / 0x100; // first (most significant) byte of our port
    


    ryanofsky commented at 7:36 PM on April 5, 2019:

    In commit "docs: netaddress: Add CService::GetKey docs" (b3697888fcff02eccc84521c2b64e0ae21a8236a)

    Would drop first/second and just say most significant/least significant or high/low.

    With first/second it sounds like this is making an assumption about the byte order.

  23. ryanofsky approved
  24. ryanofsky commented at 7:50 PM on April 5, 2019: member

    utACK cf19e24e77b35ca013dab4cc950cf89eafb8e95f. Nice change. Left some suggestions but feel free to ignore them.

  25. dongcarl force-pushed on Apr 8, 2019
  26. dongcarl commented at 3:52 PM on April 8, 2019: member

    @ryanofsky Thanks for the detailed comments. Definitely clearer and better wordings. Fixed!

  27. practicalswift commented at 4:16 PM on April 8, 2019: contributor

    Please squash and this should be ready for merge :-)

  28. dongcarl force-pushed on Apr 8, 2019
  29. dongcarl commented at 9:01 PM on April 8, 2019: member

    Squashed.

  30. ryanofsky approved
  31. ryanofsky commented at 2:59 PM on April 9, 2019: member

    utACK c99497c85f3576a4f4c8ede56074d81b59bfe57a. Just rebase, squash and a few suggested changes since last review. Since the PR is documentation only and the comments are easy to verify, this might be a good candidate for merge soon.

  32. dongcarl force-pushed on Apr 10, 2019
  33. docs: Improve netaddress comments
    - Improve IsRFC methods docs
    - Improve {Is,Set}Internal docs
    - Add tor methods docs
    - Add IsIPv{4,6} docs
    - Add IsValid docs
    - Add IsRoutable docs
    - Improve GetGroup docs
    - Add CService::GetSockAddr docs
    - Add CService::GetKey docs
    - Add CSubNet::Match docs
    - Add NetmaskBits docs
    - Add CNetAddr default constructor docs
    303372c41a
  34. dongcarl commented at 3:48 PM on April 10, 2019: member

    Added doc for CNetAddr's default constructor as its implicit properties are used elsewhere in the codebase.

  35. laanwj merged this on Apr 11, 2019
  36. laanwj closed this on Apr 11, 2019

  37. laanwj referenced this in commit bb68abe784 on Apr 11, 2019
  38. laanwj referenced this in commit fc6cbc31e9 on Jun 6, 2019
  39. sidhujag referenced this in commit 6ed4ed7389 on Jun 6, 2019
  40. deadalnix referenced this in commit 9dca86e63a on Jun 9, 2020
  41. PastaPastaPasta referenced this in commit 89e7638f30 on Jan 16, 2021
  42. UdjinM6 referenced this in commit 1c48eb2faf on Jan 18, 2021
  43. PastaPastaPasta referenced this in commit 233232ce3e on Jan 18, 2021
  44. DrahtBot locked this on Dec 16, 2021

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-22 18:14 UTC

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