Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115742
D8727.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
D8727.diff
View Options
diff --git a/src/net.h b/src/net.h
--- a/src/net.h
+++ b/src/net.h
@@ -880,6 +880,21 @@
std::atomic_bool fPauseRecv{false};
std::atomic_bool fPauseSend{false};
+ bool IsOutboundOrBlockRelayConn() const {
+ switch (m_conn_type) {
+ case ConnectionType::OUTBOUND:
+ case ConnectionType::BLOCK_RELAY:
+ return true;
+ case ConnectionType::INBOUND:
+ case ConnectionType::MANUAL:
+ case ConnectionType::ADDR_FETCH:
+ case ConnectionType::FEELER:
+ return false;
+ }
+
+ assert(false);
+ }
+
bool IsFullOutboundConn() const {
return m_conn_type == ConnectionType::OUTBOUND;
}
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1788,11 +1788,10 @@
{
LOCK(cs_vNodes);
for (const CNode *pnode : vNodes) {
- nRelevant += pnode->fSuccessfullyConnected &&
- !pnode->IsFeelerConn() &&
- !pnode->IsAddrFetchConn() &&
- !pnode->IsManualConn() &&
- !pnode->IsInboundConn();
+ if (pnode->fSuccessfullyConnected &&
+ pnode->IsOutboundOrBlockRelayConn()) {
+ ++nRelevant;
+ }
}
}
if (nRelevant >= 2) {
@@ -1916,9 +1915,8 @@
{
LOCK(cs_vNodes);
for (const CNode *pnode : vNodes) {
- if (!pnode->IsInboundConn() && !pnode->IsManualConn() &&
- !pnode->IsFeelerConn() && !pnode->fDisconnect &&
- !pnode->IsAddrFetchConn() && pnode->fSuccessfullyConnected) {
+ if (pnode->fSuccessfullyConnected && !pnode->fDisconnect &&
+ pnode->IsOutboundOrBlockRelayConn()) {
++nOutbound;
}
}
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -935,8 +935,7 @@
}
static bool IsOutboundDisconnectionCandidate(const CNode &node) {
- return !(node.IsInboundConn() || node.IsManualConn() ||
- node.IsFeelerConn() || node.IsAddrFetchConn());
+ return node.IsOutboundOrBlockRelayConn();
}
void PeerLogicValidation::InitializeNode(const Config &config, CNode *pnode) {
@@ -2538,8 +2537,8 @@
if (!pfrom.IsInboundConn()) {
connman.SetServices(pfrom.addr, nServices);
}
- if (!pfrom.IsInboundConn() && !pfrom.IsFeelerConn() &&
- !pfrom.IsManualConn() && !HasAllDesirableServiceFlags(nServices)) {
+ if (pfrom.ExpectServicesFromConn() &&
+ !HasAllDesirableServiceFlags(nServices)) {
LogPrint(BCLog::NET,
"peer=%d does not offer the expected services "
"(%08x offered, %08x expected); disconnecting\n",
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:55 (3 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187731
Default Alt Text
D8727.diff (3 KB)
Attached To
D8727: [net/refactor] Simplify multiple-connection checks
Event Timeline
Log In to Comment