From 44407100ff9b478d6131a1c38ee993b50b1830df Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 4 Oct 2017 17:59:30 -0400 Subject: Replace relevant services logic with a function suite. Adds HasAllRelevantServices and GetRelevantServices, which check for NETWORK|WITNESS. This changes the following: * Removes nRelevantServices from CConnman, disconnecting it a bit more from protocol-level logic. * Replaces our sometimes-connect-to-!WITNESS-nodes logic with simply always requiring WITNESS|NETWORK for outbound non-feeler connections (feelers still only require NETWORK). * This has the added benefit of removing nServicesExpected from CNode - instead letting net_processing's VERSION message handling simply check HasAllRelevantServices. * This implies we believe WITNESS nodes to continue to be a significant majority of nodes on the network, but also because we cannot sync properly from !WITNESS nodes, it is strange to continue using our valuable outbound slots on them. * In order to prevent this change from preventing connection to -connect= nodes which have !WITNESS, -connect nodes are now given the "addnode" flag. This also allows outbound connections to !NODE_NETWORK nodes for -connect nodes (which was already true of addnodes). * Has the (somewhat unintended) consequence of changing one of the eviction metrics from the same sometimes-connect-to-!WITNESS-nodes metric to requiring HasRelevantServices. This should make NODE_NETWORK_LIMITED much simpler to implement. --- src/rpc/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/rpc') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index a3d3df26a3..fa0d15e0cd 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -217,7 +217,7 @@ UniValue addnode(const JSONRPCRequest& request) if (strCommand == "onetry") { CAddress addr; - g_connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str()); + g_connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), false, false, true); return NullUniValue; } -- cgit v1.2.3 From 57edc0b0c86549020a39cd65f96496e9771c4769 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 5 Oct 2017 11:49:16 -0400 Subject: Rename fAddnode to a more-descriptive "manual_connection" --- src/rpc/net.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/rpc') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index fa0d15e0cd..076fe260bc 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -92,7 +92,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request) " \"version\": v, (numeric) The peer version, such as 7001\n" " \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n" " \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n" - " \"addnode\": true|false, (boolean) Whether connection was due to addnode and is using an addnode slot\n" + " \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n" " \"startingheight\": n, (numeric) The starting height (block) of the peer\n" " \"banscore\": n, (numeric) The ban score\n" " \"synced_headers\": n, (numeric) The last header we have in common with this peer\n" @@ -156,7 +156,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request) // their ver message. obj.push_back(Pair("subver", stats.cleanSubVer)); obj.push_back(Pair("inbound", stats.fInbound)); - obj.push_back(Pair("addnode", stats.fAddnode)); + obj.push_back(Pair("addnode", stats.m_manual_connection)); obj.push_back(Pair("startingheight", stats.nStartingHeight)); if (fStateStats) { obj.push_back(Pair("banscore", statestats.nMisbehavior)); -- cgit v1.2.3 From 5ee88b4bdefecbf03b6883b2a6b56a44ec75167d Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 6 Oct 2017 17:27:04 -0400 Subject: Clarify docs for requirements/handling of addnode/connect nodes --- src/rpc/net.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/rpc') diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 076fe260bc..8fb8328c5e 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -201,6 +201,8 @@ UniValue addnode(const JSONRPCRequest& request) "addnode \"node\" \"add|remove|onetry\"\n" "\nAttempts to add or remove a node from the addnode list.\n" "Or try a connection to a node once.\n" + "Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be\n" + "full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).\n" "\nArguments:\n" "1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n" "2. \"command\" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once\n" -- cgit v1.2.3