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-
luke-jr commented at 7:46 pm on August 20, 2020: memberRefactor split out of #17167
-
DrahtBot added the label GUI on Aug 20, 2020
-
DrahtBot added the label Mining on Aug 20, 2020
-
DrahtBot added the label P2P on Aug 20, 2020
-
DrahtBot added the label RPC/REST/ZMQ on Aug 20, 2020
-
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:kin 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 wayluke-jr force-pushed on Aug 20, 2020in 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?
DrahtBot commented at 5:59 am on August 21, 2020: memberThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Conflicts
No conflicts as of last run.
MarcoFalke removed the label GUI on Aug 21, 2020MarcoFalke removed the label Mining on Aug 21, 2020MarcoFalke removed the label RPC/REST/ZMQ on Aug 21, 2020MarcoFalke added the label Refactoring on Aug 21, 2020practicalswift commented at 6:03 am on August 23, 2020: contributorConcept ACK:enum class
is strictly betterpromag commented at 10:52 pm on August 23, 2020: memberCode review ACK 8727019ec307badb3bca363cc8bc832aaea4c058, just needs to format correctly apparently.DrahtBot added the label Needs rebase on Sep 4, 2020luke-jr force-pushed on Sep 11, 2020luke-jr requested review from MarcoFalke on Sep 11, 2020luke-jr requested review from promag on Sep 11, 2020DrahtBot removed the label Needs rebase on Sep 11, 2020in 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 insrc/net.cpp:2736
(at least, currently)0 if (flags & (pnode->IsInboundConn() ? ConnectionDirection::In : ConnectionDirection::Out)) {
MarcoFalke approvedMarcoFalke commented at 6:18 pm on September 23, 2020: memberACKDrahtBot added the label Needs rebase on Sep 23, 2020luke-jr force-pushed on Oct 30, 2020DrahtBot removed the label Needs rebase on Oct 30, 2020practicalswift commented at 11:01 pm on October 30, 2020: contributorACK 40bc8d725f6542697a0580df0087b230959a3db7: patch looks correctDrahtBot added the label Needs rebase on Dec 1, 2020net: Replace enum CConnMan::NumConnections with enum class ConnectionDirection c77de622ddluke-jr force-pushed on Mar 4, 2021DrahtBot removed the label Needs rebase on Mar 4, 2021practicalswift commented at 7:21 am on March 6, 2021: contributorcr ACK c77de622dd8ef458f73b1a01a34629a7c4f49358: patch looks correct &enum class
is strictly betterMarcoFalke merged this on Mar 7, 2021MarcoFalke closed this on Mar 7, 2021
laanwj referenced this in commit 4da26fb85d on May 19, 2021DrahtBot 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-11-17 12:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me