net: Replace enum CConnMan::NumConnections with enum class ConnectionDirection #19771

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:enum_conndir changing 9 files +36 −24
  1. luke-jr commented at 7:46 PM on August 20, 2020: member

    Refactor split out of #17167

  2. DrahtBot added the label GUI on Aug 20, 2020
  3. DrahtBot added the label Mining on Aug 20, 2020
  4. DrahtBot added the label P2P on Aug 20, 2020
  5. DrahtBot added the label RPC/REST/ZMQ on Aug 20, 2020
  6. in src/netbase.h:39 in f3aadf86da outdated
      30 | +        In = (1U << 0),
      31 | +        Out = (1U << 1),
      32 | +        Both = (In | Out),
      33 | +};
      34 | +static inline ConnectionDirection& operator|=(ConnectionDirection& a, ConnectionDirection b) {
      35 | +    using underlying = typename std::underlying_type<ConnectionDirection>::type;
    


    promag commented at 10:40 PM on August 20, 2020:

    Add #include <type_traits>.


    luke-jr commented at 11:43 PM on August 20, 2020:

    k

  7. in src/netbase.h:40 in f3aadf86da outdated
      31 | +        Out = (1U << 1),
      32 | +        Both = (In | Out),
      33 | +};
      34 | +static inline ConnectionDirection& operator|=(ConnectionDirection& a, ConnectionDirection b) {
      35 | +    using underlying = typename std::underlying_type<ConnectionDirection>::type;
      36 | +    a = ConnectionDirection(underlying(a) | underlying(b));
    


    promag commented at 10:42 PM on August 20, 2020:

    nit, return a = ...?


    luke-jr commented at 11:43 PM on August 20, 2020:

    I think it's more readable the current way

  8. luke-jr force-pushed on Aug 20, 2020
  9. in src/netbase.h:33 in 8727019ec3 outdated
      25 | @@ -25,6 +26,22 @@ static const int DEFAULT_CONNECT_TIMEOUT = 5000;
      26 |  //! -dns default
      27 |  static const int DEFAULT_NAME_LOOKUP = true;
      28 |  
      29 | +enum class ConnectionDirection {
      30 | +        None = 0,
      31 | +        In = (1U << 0),
      32 | +        Out = (1U << 1),
      33 | +        Both = (In | Out),
    


    MarcoFalke commented at 5:38 AM on August 21, 2020:

    Any reason the new code is not clang formatted?


    luke-jr commented at 2:02 PM on September 11, 2020:

    I don't see any documented way to do that (contrib/devtools/clang-format-diff.py wants to make a bunch of unrelated changes).

    Fixed indentation. Anything else?

  10. DrahtBot commented at 5:59 AM on August 21, 2020: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    No conflicts as of last run.

  11. MarcoFalke removed the label GUI on Aug 21, 2020
  12. MarcoFalke removed the label Mining on Aug 21, 2020
  13. MarcoFalke removed the label RPC/REST/ZMQ on Aug 21, 2020
  14. MarcoFalke added the label Refactoring on Aug 21, 2020
  15. DrahtBot cross-referenced this on Aug 21, 2020 from issue Per-Peer Message Capture by troygiorshev
  16. DrahtBot cross-referenced this on Aug 21, 2020 from issue rpc, cli: add network in/out connections to `getnetworkinfo` and `-getinfo` by jonatack
  17. DrahtBot cross-referenced this on Aug 21, 2020 from issue [tests] Allow outbound & block-relay-only connections in functional tests. by amitiuttarwar
  18. DrahtBot cross-referenced this on Aug 21, 2020 from issue qt: Deduplicate NumConnections enum by hebasto
  19. DrahtBot cross-referenced this on Aug 21, 2020 from issue p2p: Move all header verification into the network layer, extend logging by troygiorshev
  20. DrahtBot cross-referenced this on Aug 21, 2020 from issue bloom: use Span instead of std::vector for `insert` and `contains` [ZAP3] by jb55
  21. DrahtBot cross-referenced this on Aug 21, 2020 from issue interfaces: Expose settings.json methods to GUI by ryanofsky
  22. practicalswift commented at 6:03 AM on August 23, 2020: contributor

    Concept ACK: enum class is strictly better

  23. promag commented at 10:52 PM on August 23, 2020: member

    Code review ACK 8727019ec307badb3bca363cc8bc832aaea4c058, just needs to format correctly apparently.

  24. DrahtBot cross-referenced this on Aug 31, 2020 from issue rpc: remove deprecated CRPCCommand constructor by MarcoFalke
  25. DrahtBot added the label Needs rebase on Sep 4, 2020
  26. luke-jr force-pushed on Sep 11, 2020
  27. luke-jr requested review from MarcoFalke on Sep 11, 2020
  28. luke-jr requested review from promag on Sep 11, 2020
  29. DrahtBot removed the label Needs rebase on Sep 11, 2020
  30. DrahtBot cross-referenced this on Sep 19, 2020 from issue signet mining utility by ajtowns
  31. DrahtBot cross-referenced this on Sep 22, 2020 from issue Assert that RPCArg names are equal to CRPCCommand ones (net, rpcwallet) by MarcoFalke
  32. in src/netbase.h:46 in 4ed32388d3 outdated
      38 | +    return a;
      39 | +}
      40 | +static inline bool operator&(ConnectionDirection a, ConnectionDirection b) {
      41 | +    using underlying = typename std::underlying_type<ConnectionDirection>::type;
      42 | +    return (underlying(a) & underlying(b));
      43 | +}
    


    MarcoFalke commented at 6:18 PM on September 23, 2020:

    Seems a bit odd to add unused code, but no strong opinion.


    jonatack commented at 8:20 PM on March 22, 2021:

    Seems a bit odd to add unused code, but no strong opinion.

    If I understand the comment correctly, this operator& code is used in src/net.cpp:2736 (at least, currently)

            if (flags & (pnode->IsInboundConn() ? ConnectionDirection::In : ConnectionDirection::Out)) {
    
  33. MarcoFalke approved
  34. MarcoFalke commented at 6:18 PM on September 23, 2020: member

    ACK

  35. DrahtBot added the label Needs rebase on Sep 23, 2020
  36. luke-jr force-pushed on Oct 30, 2020
  37. DrahtBot removed the label Needs rebase on Oct 30, 2020
  38. practicalswift commented at 11:01 PM on October 30, 2020: contributor

    ACK 40bc8d725f6542697a0580df0087b230959a3db7: patch looks correct

  39. DrahtBot cross-referenced this on Oct 31, 2020 from issue rpc, net: Expose connections_onion_only in getnetworkinfo RPC output by hebasto
  40. DrahtBot cross-referenced this on Nov 11, 2020 from issue Follow-ups to 19107 by troygiorshev
  41. DrahtBot cross-referenced this on Nov 25, 2020 from issue refactor: Move node and wallet code out of src/interfaces by ryanofsky
  42. DrahtBot cross-referenced this on Nov 25, 2020 from issue multiprocess: Add basic spawn and IPC support by ryanofsky
  43. DrahtBot cross-referenced this on Nov 26, 2020 from issue multiprocess: Add bitcoin-gui -ipcconnect option by ryanofsky
  44. DrahtBot cross-referenced this on Nov 26, 2020 from issue multiprocess: Add bitcoin-wallet -ipcconnect option by ryanofsky
  45. DrahtBot cross-referenced this on Nov 26, 2020 from issue Multiprocess bitcoin by ryanofsky
  46. DrahtBot added the label Needs rebase on Dec 1, 2020
  47. net: Replace enum CConnMan::NumConnections with enum class ConnectionDirection c77de622dd
  48. luke-jr force-pushed on Mar 4, 2021
  49. DrahtBot removed the label Needs rebase on Mar 4, 2021
  50. practicalswift commented at 7:21 AM on March 6, 2021: contributor

    cr ACK c77de622dd8ef458f73b1a01a34629a7c4f49358: patch looks correct & enum class is strictly better

  51. MarcoFalke merged this on Mar 7, 2021
  52. MarcoFalke closed this on Mar 7, 2021

  53. jonatack cross-referenced this on Mar 22, 2021 from issue p2p, refactor: make NetPermissionFlags an enum class by jonatack
  54. laanwj referenced this in commit 4da26fb85d on May 19, 2021
  55. JaredTate cross-referenced this on Oct 30, 2021 from issue WIP: Feature/8.22.0 Random Crash Bug & Missing Dandelion Relay TX Code by JaredTate
  56. bitcoin 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-05-19 06:53 UTC