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: member

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

    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. practicalswift commented at 6:03 am on August 23, 2020: contributor
    Concept ACK: enum class is strictly better
  16. promag commented at 10:52 pm on August 23, 2020: member
    Code review ACK 8727019ec307badb3bca363cc8bc832aaea4c058, just needs to format correctly apparently.
  17. DrahtBot added the label Needs rebase on Sep 4, 2020
  18. luke-jr force-pushed on Sep 11, 2020
  19. luke-jr requested review from MarcoFalke on Sep 11, 2020
  20. luke-jr requested review from promag on Sep 11, 2020
  21. DrahtBot removed the label Needs rebase on Sep 11, 2020
  22. 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)

    0        if (flags & (pnode->IsInboundConn() ? ConnectionDirection::In : ConnectionDirection::Out)) {
    
  23. MarcoFalke approved
  24. MarcoFalke commented at 6:18 pm on September 23, 2020: member
    ACK
  25. DrahtBot added the label Needs rebase on Sep 23, 2020
  26. luke-jr force-pushed on Oct 30, 2020
  27. DrahtBot removed the label Needs rebase on Oct 30, 2020
  28. practicalswift commented at 11:01 pm on October 30, 2020: contributor
    ACK 40bc8d725f6542697a0580df0087b230959a3db7: patch looks correct
  29. DrahtBot added the label Needs rebase on Dec 1, 2020
  30. net: Replace enum CConnMan::NumConnections with enum class ConnectionDirection c77de622dd
  31. luke-jr force-pushed on Mar 4, 2021
  32. DrahtBot removed the label Needs rebase on Mar 4, 2021
  33. practicalswift commented at 7:21 am on March 6, 2021: contributor
    cr ACK c77de622dd8ef458f73b1a01a34629a7c4f49358: patch looks correct & enum class is strictly better
  34. MarcoFalke merged this on Mar 7, 2021
  35. MarcoFalke closed this on Mar 7, 2021

  36. laanwj referenced this in commit 4da26fb85d on May 19, 2021
  37. 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: 2024-12-18 18:12 UTC

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