This ensures that future flags can be turned off after being enabled without causing all outbound nodes to refuse to connect to it in the future for lack of expected services.
Should probably be backported to 0.14 as well.
This ensures that future flags can be turned off after being enabled without causing all outbound nodes to refuse to connect to it in the future for lack of expected services.
Should probably be backported to 0.14 as well.
utACK 0f1e7d3623f37d8ba12ea63543794c90682567bd
utACK 7e1718d
utACK 7e1718d
(re)utACK 7e1718d389d6cb1223124cefa594f136f56ec4d1
Perhaps consider bracing the conditionals? (at least the new ones?)
@gmaxwell done. diff from before is cosmetic only:
diff --git a/src/net.cpp b/src/net.cpp
index 1e50cfb..22d26a9 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1796,11 +1796,13 @@ void CConnman::ThreadOpenConnections()
// only consider nodes missing relevant services after 40 failed attempts and only if less than half the outbound are up.
ServiceFlags nRequiredServices = nRelevantServices;
- if (nTries >= 40 && nOutbound < (nMaxOutbound >> 1))
+ if (nTries >= 40 && nOutbound < (nMaxOutbound >> 1)) {
nRequiredServices = REQUIRED_SERVICES;
+ }
- if ((addr.nServices & nRequiredServices) != nRequiredServices)
+ if ((addr.nServices & nRequiredServices) != nRequiredServices) {
continue;
+ }
// do not allow non-default ports, unless after 50 invalid addresses selected already
if (addr.GetPort() != Params().GetDefaultPort() && nTries < 50)
1812 | addrConnect = addr; 1813 | + 1814 | + // regardless of the services assumed to be available, only require the minimum if half or more outbound have relevant services 1815 | + if (nOutboundRelevant >= (nMaxOutbound >> 1)) { 1816 | + addrConnect.nServices = REQUIRED_SERVICES; 1817 | + } else {
I think this else branch is unnecessary?
Indeed!
net.cpp: In member function ‘void CConnman::ThreadOpenConnections()’:
net.cpp:1732:115: warning: self-comparison always evaluates to true [-Wtautological-compare]
if (pnode->fSuccessfullyConnected && !pnode->fFeeler && (pnode->nServices & nRelevantServices == nRelevantServices)) {
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
net.cpp:1732:115: warning: suggest parentheses around comparison in operand of ‘&’ [-Wparentheses]
Yikes, thanks. Pushed the fixup.
also once half of all outgoing nodes have our preferred flags, require only
minimal flags from the rest.
utACK b6fbfc228236947eaea5c14dda299f5a01810e92