Skip to content

Commit f8c310a

Browse files
sipacodablock
authored andcommitted
Merge bitcoin#11456: Replace relevant services logic with a function suite.
15f5d3b Switch DNSSeed-needed metric to any-automatic-nodes, not services (Matt Corallo) 5ee88b4 Clarify docs for requirements/handling of addnode/connect nodes (Matt Corallo) 57edc0b Rename fAddnode to a more-descriptive "manual_connection" (Matt Corallo) 4440710 Replace relevant services logic with a function suite. (Matt Corallo) Pull request description: This was mostly written as a way to clean things up so that the NETWORK_LIMITED PR (bitcoin#10387) can be simplified a ton, but its also a nice standalone cleanup that will also require a bit of review because it tweaks a lot of stuff across net. The new functions are fine in protocol.h right now since they're straight-forward, but after NETWORK_LIMITED will really want to move elsewhere after @theuni moves the nServices-based selection to addrman from connman. 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. Tree-SHA512: 90606896c86cc5da14c77843b16674a6a012065e7b583d76d1c47a18215358abefcbab44ff4fab3fadcd39aa9a42d4740c6dc8874a58033bdfc8ad3fb5c649fc
1 parent 35d60de commit f8c310a

File tree

6 files changed

+72
-60
lines changed

6 files changed

+72
-60
lines changed

src/init.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,12 +487,12 @@ std::string HelpMessage(HelpMessageMode mode)
487487
strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX));
488488

489489
strUsage += HelpMessageGroup(_("Connection options:"));
490-
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
490+
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info)"));
491491
strUsage += HelpMessageOpt("-allowprivatenet", strprintf(_("Allow RFC1918 addresses to be relayed and connected to (default: %u)"), DEFAULT_ALLOWPRIVATENET));
492492
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
493493
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
494494
strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
495-
strUsage += HelpMessageOpt("-connect=<ip>", _("Connect only to the specified node(s); -connect=0 disables automatic connections"));
495+
strUsage += HelpMessageOpt("-connect=<ip>", _("Connect only to the specified node(s); -connect=0 disables automatic connections (the rules for this peer are the same as for -addnode)"));
496496
strUsage += HelpMessageOpt("-discover", _("Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
497497
strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + strprintf(_("(default: %u)"), DEFAULT_NAME_LOOKUP));
498498
strUsage += HelpMessageOpt("-dnsseed", _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)"));
@@ -1016,7 +1016,6 @@ void InitLogging()
10161016

10171017
namespace { // Variables internal to initialization process only
10181018

1019-
ServiceFlags nRelevantServices = NODE_NETWORK;
10201019
int nMaxConnections;
10211020
int nUserMaxConnections;
10221021
int nFD;
@@ -2122,7 +2121,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
21222121

21232122
CConnman::Options connOptions;
21242123
connOptions.nLocalServices = nLocalServices;
2125-
connOptions.nRelevantServices = nRelevantServices;
21262124
connOptions.nMaxConnections = nMaxConnections;
21272125
connOptions.nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, connOptions.nMaxConnections);
21282126
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;

src/net.cpp

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
436436
uint64_t nonce = GetDeterministicRandomizer(RANDOMIZER_ID_LOCALHOSTNONCE).Write(id).Finalize();
437437
CAddress addr_bind = GetBindAddress(hSocket);
438438
CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", false);
439-
pnode->nServicesExpected = ServiceFlags(addrConnect.nServices & nRelevantServices);
440439
pnode->AddRef();
441440

442441

@@ -688,7 +687,7 @@ void CNode::copyStats(CNodeStats &stats)
688687
X(cleanSubVer);
689688
}
690689
X(fInbound);
691-
X(fAddnode);
690+
X(m_manual_connection);
692691
X(nStartingHeight);
693692
{
694693
LOCK(cs_vSend);
@@ -1026,7 +1025,7 @@ bool CConnman::AttemptToEvictConnection()
10261025

10271026
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime,
10281027
node->nLastBlockTime, node->nLastTXTime,
1029-
(node->nServices & nRelevantServices) == nRelevantServices,
1028+
HasAllDesirableServiceFlags(node->nServices),
10301029
node->fRelayTxes, node->pfilter != nullptr, node->nKeyedNetGroup};
10311030
vEvictionCandidates.push_back(candidate);
10321031
}
@@ -1717,7 +1716,7 @@ void CConnman::ThreadDNSAddressSeed()
17171716
LOCK(cs_vNodes);
17181717
int nRelevant = 0;
17191718
for (auto pnode : vNodes) {
1720-
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
1719+
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
17211720
}
17221721
if (nRelevant >= 2) {
17231722
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
@@ -1739,7 +1738,7 @@ void CConnman::ThreadDNSAddressSeed()
17391738
} else {
17401739
std::vector<CNetAddr> vIPs;
17411740
std::vector<CAddress> vAdd;
1742-
ServiceFlags requiredServiceBits = nRelevantServices;
1741+
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
17431742
std::string host = GetDNSHost(seed, &requiredServiceBits);
17441743
CNetAddr resolveSource;
17451744
if (!resolveSource.SetInternal(host)) {
@@ -1820,7 +1819,7 @@ void CConnman::ThreadOpenConnections()
18201819
for (const std::string& strAddr : gArgs.GetArgs("-connect"))
18211820
{
18221821
CAddress addr(CService(), NODE_NONE);
1823-
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str());
1822+
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str(), false, false, true);
18241823
for (int i = 0; i < 10 && i < nLoop; i++)
18251824
{
18261825
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
@@ -1869,17 +1868,11 @@ void CConnman::ThreadOpenConnections()
18691868
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
18701869
// This is only done for mainnet and testnet
18711870
int nOutbound = 0;
1872-
int nOutboundRelevant = 0;
18731871
std::set<std::vector<unsigned char> > setConnected;
18741872
if (!Params().AllowMultipleAddressesFromGroup()) {
18751873
LOCK(cs_vNodes);
18761874
for (CNode* pnode : vNodes) {
1877-
if (!pnode->fInbound && !pnode->fAddnode && !pnode->fMasternode) {
1878-
1879-
// Count the peers that have all relevant services
1880-
if (pnode->fSuccessfullyConnected && !pnode->fFeeler && ((pnode->nServices & nRelevantServices) == nRelevantServices)) {
1881-
nOutboundRelevant++;
1882-
}
1875+
if (!pnode->fInbound && !pnode->fMasternode && !pnode->m_manual_connection) {
18831876
// Netgroups for inbound and addnode peers are not excluded because our goal here
18841877
// is to not use multiple of our limited outbound slots on a single netgroup
18851878
// but inbound and addnode peers do not use our outbound slots. Inbound peers
@@ -1943,21 +1936,16 @@ void CConnman::ThreadOpenConnections()
19431936
if (IsLimited(addr))
19441937
continue;
19451938

1946-
// only connect to full nodes
1947-
if (!isMasternode && (addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES)
1948-
continue;
1949-
19501939
// only consider very recently tried nodes after 30 failed attempts
19511940
if (nANow - addr.nLastTry < 600 && nTries < 30)
19521941
continue;
19531942

1954-
// only consider nodes missing relevant services after 40 failed attempts and only if less than half the outbound are up.
1955-
ServiceFlags nRequiredServices = nRelevantServices;
1956-
if (nTries >= 40 && nOutbound < (nMaxOutbound >> 1)) {
1957-
nRequiredServices = REQUIRED_SERVICES;
1958-
}
1959-
1960-
if (!isMasternode && (addr.nServices & nRequiredServices) != nRequiredServices) {
1943+
// for non-feelers, require all the services we'll want,
1944+
// for feelers, only require they be a full node (only because most
1945+
// SPV clients don't have a good address DB available)
1946+
if (!isMasternode && !fFeeler && !HasAllDesirableServiceFlags(addr.nServices)) {
1947+
continue;
1948+
} else if (!isMasternode && fFeeler && !MayHaveUsefulAddressDB(addr.nServices)) {
19611949
continue;
19621950
}
19631951

@@ -1966,13 +1954,6 @@ void CConnman::ThreadOpenConnections()
19661954
continue;
19671955

19681956
addrConnect = addr;
1969-
1970-
// regardless of the services assumed to be available, only require the minimum if half or more outbound have relevant services
1971-
if (nOutboundRelevant >= (nMaxOutbound >> 1)) {
1972-
addrConnect.nServices = REQUIRED_SERVICES;
1973-
} else {
1974-
addrConnect.nServices = nRequiredServices;
1975-
}
19761957
break;
19771958
}
19781959

@@ -2165,7 +2146,7 @@ void CConnman::ThreadOpenMasternodeConnections()
21652146
}
21662147

21672148
// if successful, this moves the passed grant to the constructed node
2168-
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool fAddnode, bool fConnectToMasternode)
2149+
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection, bool fConnectToMasternode)
21692150
{
21702151
//
21712152
// Initiate outbound network connection
@@ -2201,8 +2182,8 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
22012182
pnode->fOneShot = true;
22022183
if (fFeeler)
22032184
pnode->fFeeler = true;
2204-
if (fAddnode)
2205-
pnode->fAddnode = true;
2185+
if (manual_connection)
2186+
pnode->m_manual_connection = true;
22062187
if (fConnectToMasternode)
22072188
pnode->fMasternode = true;
22082189

@@ -3138,7 +3119,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
31383119
nSendVersion(0)
31393120
{
31403121
nServices = NODE_NONE;
3141-
nServicesExpected = NODE_NONE;
31423122
hSocket = hSocketIn;
31433123
nRecvVersion = INIT_PROTO_VERSION;
31443124
nLastSend = 0;
@@ -3153,7 +3133,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
31533133
strSubVer = "";
31543134
fWhitelisted = false;
31553135
fOneShot = false;
3156-
fAddnode = false;
3136+
m_manual_connection = false;
31573137
fClient = false; // set by version message
31583138
fFeeler = false;
31593139
fSuccessfullyConnected = false;

src/net.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ static const bool DEFAULT_FORCEDNSSEED = false;
111111
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
112112
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
113113

114-
static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;
115-
116114
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
117115
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
118116

@@ -157,7 +155,6 @@ class CConnman
157155
struct Options
158156
{
159157
ServiceFlags nLocalServices = NODE_NONE;
160-
ServiceFlags nRelevantServices = NODE_NONE;
161158
int nMaxConnections = 0;
162159
int nMaxOutbound = 0;
163160
int nMaxAddnode = 0;
@@ -175,7 +172,6 @@ class CConnman
175172

176173
void Init(const Options& connOptions) {
177174
nLocalServices = connOptions.nLocalServices;
178-
nRelevantServices = connOptions.nRelevantServices;
179175
nMaxConnections = connOptions.nMaxConnections;
180176
nMaxOutbound = std::min(connOptions.nMaxOutbound, connOptions.nMaxConnections);
181177
nMaxAddnode = connOptions.nMaxAddnode;
@@ -196,7 +192,7 @@ class CConnman
196192
void Interrupt();
197193
bool GetNetworkActive() const { return fNetworkActive; };
198194
void SetNetworkActive(bool active);
199-
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool fAddnode = false, bool fConnectToMasternode = false);
195+
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false, bool fConnectToMasternode = false);
200196
bool OpenMasternodeConnection(const CAddress& addrConnect);
201197
bool CheckIncomingNonce(uint64_t nonce);
202198

@@ -532,9 +528,6 @@ class CConnman
532528
/** Services this instance offers */
533529
ServiceFlags nLocalServices;
534530

535-
/** Services this instance cares about */
536-
ServiceFlags nRelevantServices;
537-
538531
CSemaphore *semOutbound;
539532
CSemaphore *semAddnode;
540533
CSemaphore *semMasternodeOutbound;
@@ -663,7 +656,7 @@ class CNodeStats
663656
int nVersion;
664657
std::string cleanSubVer;
665658
bool fInbound;
666-
bool fAddnode;
659+
bool m_manual_connection;
667660
int nStartingHeight;
668661
uint64_t nSendBytes;
669662
mapMsgCmdSize mapSendBytesPerMsgCmd;
@@ -735,7 +728,6 @@ class CNode
735728
public:
736729
// socket
737730
std::atomic<ServiceFlags> nServices;
738-
ServiceFlags nServicesExpected;
739731
SOCKET hSocket;
740732
size_t nSendSize; // total size of all vSendMsg entries
741733
size_t nSendOffset; // offset inside the first vSendMsg already sent
@@ -777,7 +769,7 @@ class CNode
777769
bool fWhitelisted; // This peer can bypass DoS banning.
778770
bool fFeeler; // If true this node is being used as a short lived feeler.
779771
bool fOneShot;
780-
bool fAddnode;
772+
bool m_manual_connection;
781773
bool fClient;
782774
const bool fInbound;
783775
std::atomic_bool fSuccessfullyConnected;

src/net_processing.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,11 +1456,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
14561456
{
14571457
connman.SetServices(pfrom->addr, nServices);
14581458
}
1459-
if (pfrom->nServicesExpected & ~nServices)
1459+
if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices))
14601460
{
1461-
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, pfrom->nServicesExpected);
1461+
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices));
14621462
connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
1463-
strprintf("Expected to offer services %08x", pfrom->nServicesExpected)));
1463+
strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices))));
14641464
pfrom->fDisconnect = true;
14651465
return false;
14661466
}
@@ -1697,7 +1697,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
16971697
if (interruptMsgProc)
16981698
return true;
16991699

1700-
if ((addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES)
1700+
// We only bother storing full nodes, though this may include
1701+
// things which we would not make an outbound connection to, in
1702+
// part because we may make feeler connections to them.
1703+
if (!MayHaveUsefulAddressDB(addr.nServices))
17011704
continue;
17021705

17031706
if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
@@ -3001,8 +3004,8 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman& connman)
30013004
state.fShouldBan = false;
30023005
if (pnode->fWhitelisted)
30033006
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->GetLogString());
3004-
else if (pnode->fAddnode)
3005-
LogPrintf("Warning: not punishing addnoded peer %s!\n", pnode->GetLogString());
3007+
else if (pnode->m_manual_connection)
3008+
LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode->GetLogString());
30063009
else {
30073010
pnode->fDisconnect = true;
30083011
if (pnode->addr.IsLocal())

src/protocol.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,43 @@ enum ServiceFlags : uint64_t {
306306
// BIP process.
307307
};
308308

309+
/**
310+
* Gets the set of service flags which are "desirable" for a given peer.
311+
*
312+
* These are the flags which are required for a peer to support for them
313+
* to be "interesting" to us, ie for us to wish to use one of our few
314+
* outbound connection slots for or for us to wish to prioritize keeping
315+
* their connection around.
316+
*
317+
* Relevant service flags may be peer- and state-specific in that the
318+
* version of the peer may determine which flags are required (eg in the
319+
* case of NODE_NETWORK_LIMITED where we seek out NODE_NETWORK peers
320+
* unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which
321+
* case NODE_NETWORK_LIMITED suffices).
322+
*
323+
* Thus, generally, avoid calling with peerServices == NODE_NONE.
324+
*/
325+
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
326+
return ServiceFlags(NODE_NETWORK | NODE_WITNESS);
327+
}
328+
329+
/**
330+
* A shortcut for (services & GetDesirableServiceFlags(services))
331+
* == GetDesirableServiceFlags(services), ie determines whether the given
332+
* set of service flags are sufficient for a peer to be "relevant".
333+
*/
334+
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) {
335+
return !(GetDesirableServiceFlags(services) & (~services));
336+
}
337+
338+
/**
339+
* Checks if a peer with the given service flags may be capable of having a
340+
* robust address-storage DB. Currently an alias for checking NODE_NETWORK.
341+
*/
342+
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) {
343+
return services & NODE_NETWORK;
344+
}
345+
309346
/** A CService with information about it as peer */
310347
class CAddress : public CService
311348
{

src/rpc/net.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
9393
" \"version\": v, (numeric) The peer version, such as 7001\n"
9494
" \"subver\": \"/Dash Core:x.x.x/\", (string) The string version\n"
9595
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
96-
" \"addnode\": true|false, (boolean) Whether connection was due to addnode and is using an addnode slot\n"
96+
" \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
9797
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
9898
" \"banscore\": n, (numeric) The ban score\n"
9999
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n"
@@ -157,7 +157,7 @@ UniValue getpeerinfo(const JSONRPCRequest& request)
157157
// their ver message.
158158
obj.push_back(Pair("subver", stats.cleanSubVer));
159159
obj.push_back(Pair("inbound", stats.fInbound));
160-
obj.push_back(Pair("addnode", stats.fAddnode));
160+
obj.push_back(Pair("addnode", stats.m_manual_connection));
161161
obj.push_back(Pair("startingheight", stats.nStartingHeight));
162162
if (fStateStats) {
163163
obj.push_back(Pair("banscore", statestats.nMisbehavior));
@@ -202,6 +202,8 @@ UniValue addnode(const JSONRPCRequest& request)
202202
"addnode \"node\" \"add|remove|onetry\"\n"
203203
"\nAttempts to add or remove a node from the addnode list.\n"
204204
"Or try a connection to a node once.\n"
205+
"Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be\n"
206+
"full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).\n"
205207
"\nArguments:\n"
206208
"1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
207209
"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"
@@ -218,7 +220,7 @@ UniValue addnode(const JSONRPCRequest& request)
218220
if (strCommand == "onetry")
219221
{
220222
CAddress addr;
221-
g_connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str());
223+
g_connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), false, false, true);
222224
return NullUniValue;
223225
}
224226

0 commit comments

Comments
 (0)