Skip to content

Commit 326a565

Browse files
committed
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
2 parents 8c2de82 + 15f5d3b commit 326a565

File tree

6 files changed

+72
-63
lines changed

6 files changed

+72
-63
lines changed

src/init.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ std::string HelpMessage(HelpMessageMode mode)
369369
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
370370

371371
strUsage += HelpMessageGroup(_("Connection options:"));
372-
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
372+
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)"));
373373
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
374374
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
375375
strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
376-
strUsage += HelpMessageOpt("-connect=<ip>", _("Connect only to the specified node(s); -connect=0 disables automatic connections"));
376+
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)"));
377377
strUsage += HelpMessageOpt("-discover", _("Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
378378
strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + strprintf(_("(default: %u)"), DEFAULT_NAME_LOOKUP));
379379
strUsage += HelpMessageOpt("-dnsseed", _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect used)"));
@@ -815,7 +815,6 @@ void InitLogging()
815815

816816
namespace { // Variables internal to initialization process only
817817

818-
ServiceFlags nRelevantServices = NODE_NETWORK;
819818
int nMaxConnections;
820819
int nUserMaxConnections;
821820
int nFD;
@@ -1604,9 +1603,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
16041603
// Note that setting NODE_WITNESS is never required: the only downside from not
16051604
// doing so is that after activation, no upgraded nodes will fetch from you.
16061605
nLocalServices = ServiceFlags(nLocalServices | NODE_WITNESS);
1607-
// Only care about others providing witness capabilities if there is a softfork
1608-
// defined.
1609-
nRelevantServices = ServiceFlags(nRelevantServices | NODE_WITNESS);
16101606
}
16111607

16121608
// ********************************************************* Step 10: import blocks
@@ -1663,7 +1659,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
16631659

16641660
CConnman::Options connOptions;
16651661
connOptions.nLocalServices = nLocalServices;
1666-
connOptions.nRelevantServices = nRelevantServices;
16671662
connOptions.nMaxConnections = nMaxConnections;
16681663
connOptions.nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, connOptions.nMaxConnections);
16691664
connOptions.nMaxAddnode = MAX_ADDNODE_CONNECTIONS;

src/net.cpp

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

450449
return pnode;
@@ -685,7 +684,7 @@ void CNode::copyStats(CNodeStats &stats)
685684
X(cleanSubVer);
686685
}
687686
X(fInbound);
688-
X(fAddnode);
687+
X(m_manual_connection);
689688
X(nStartingHeight);
690689
{
691690
LOCK(cs_vSend);
@@ -985,7 +984,7 @@ bool CConnman::AttemptToEvictConnection()
985984
continue;
986985
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime,
987986
node->nLastBlockTime, node->nLastTXTime,
988-
(node->nServices & nRelevantServices) == nRelevantServices,
987+
HasAllDesirableServiceFlags(node->nServices),
989988
node->fRelayTxes, node->pfilter != nullptr, node->addr, node->nKeyedNetGroup};
990989
vEvictionCandidates.push_back(candidate);
991990
}
@@ -1602,7 +1601,7 @@ void CConnman::ThreadDNSAddressSeed()
16021601
LOCK(cs_vNodes);
16031602
int nRelevant = 0;
16041603
for (auto pnode : vNodes) {
1605-
nRelevant += pnode->fSuccessfullyConnected && ((pnode->nServices & nRelevantServices) == nRelevantServices);
1604+
nRelevant += pnode->fSuccessfullyConnected && !pnode->fFeeler && !pnode->fOneShot && !pnode->m_manual_connection && !pnode->fInbound;
16061605
}
16071606
if (nRelevant >= 2) {
16081607
LogPrintf("P2P peers available. Skipped DNS seeding.\n");
@@ -1624,7 +1623,7 @@ void CConnman::ThreadDNSAddressSeed()
16241623
} else {
16251624
std::vector<CNetAddr> vIPs;
16261625
std::vector<CAddress> vAdd;
1627-
ServiceFlags requiredServiceBits = nRelevantServices;
1626+
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
16281627
std::string host = GetDNSHost(seed, &requiredServiceBits);
16291628
CNetAddr resolveSource;
16301629
if (!resolveSource.SetInternal(host)) {
@@ -1705,7 +1704,7 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17051704
for (const std::string& strAddr : connect)
17061705
{
17071706
CAddress addr(CService(), NODE_NONE);
1708-
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str());
1707+
OpenNetworkConnection(addr, false, nullptr, strAddr.c_str(), false, false, true);
17091708
for (int i = 0; i < 10 && i < nLoop; i++)
17101709
{
17111710
if (!interruptNet.sleep_for(std::chrono::milliseconds(500)))
@@ -1753,17 +1752,11 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
17531752
// Only connect out to one peer per network group (/16 for IPv4).
17541753
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
17551754
int nOutbound = 0;
1756-
int nOutboundRelevant = 0;
17571755
std::set<std::vector<unsigned char> > setConnected;
17581756
{
17591757
LOCK(cs_vNodes);
17601758
for (CNode* pnode : vNodes) {
1761-
if (!pnode->fInbound && !pnode->fAddnode) {
1762-
1763-
// Count the peers that have all relevant services
1764-
if (pnode->fSuccessfullyConnected && !pnode->fFeeler && ((pnode->nServices & nRelevantServices) == nRelevantServices)) {
1765-
nOutboundRelevant++;
1766-
}
1759+
if (!pnode->fInbound && !pnode->m_manual_connection) {
17671760
// Netgroups for inbound and addnode peers are not excluded because our goal here
17681761
// is to not use multiple of our limited outbound slots on a single netgroup
17691762
// but inbound and addnode peers do not use our outbound slots. Inbound peers
@@ -1818,21 +1811,16 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18181811
if (IsLimited(addr))
18191812
continue;
18201813

1821-
// only connect to full nodes
1822-
if ((addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES)
1823-
continue;
1824-
18251814
// only consider very recently tried nodes after 30 failed attempts
18261815
if (nANow - addr.nLastTry < 600 && nTries < 30)
18271816
continue;
18281817

1829-
// only consider nodes missing relevant services after 40 failed attempts and only if less than half the outbound are up.
1830-
ServiceFlags nRequiredServices = nRelevantServices;
1831-
if (nTries >= 40 && nOutbound < (nMaxOutbound >> 1)) {
1832-
nRequiredServices = REQUIRED_SERVICES;
1833-
}
1834-
1835-
if ((addr.nServices & nRequiredServices) != nRequiredServices) {
1818+
// for non-feelers, require all the services we'll want,
1819+
// for feelers, only require they be a full node (only because most
1820+
// SPV clients don't have a good address DB available)
1821+
if (!fFeeler && !HasAllDesirableServiceFlags(addr.nServices)) {
1822+
continue;
1823+
} else if (fFeeler && !MayHaveUsefulAddressDB(addr.nServices)) {
18361824
continue;
18371825
}
18381826

@@ -1841,13 +1829,6 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
18411829
continue;
18421830

18431831
addrConnect = addr;
1844-
1845-
// regardless of the services assumed to be available, only require the minimum if half or more outbound have relevant services
1846-
if (nOutboundRelevant >= (nMaxOutbound >> 1)) {
1847-
addrConnect.nServices = REQUIRED_SERVICES;
1848-
} else {
1849-
addrConnect.nServices = nRequiredServices;
1850-
}
18511832
break;
18521833
}
18531834

@@ -1946,7 +1927,7 @@ void CConnman::ThreadOpenAddedConnections()
19461927
}
19471928

19481929
// if successful, this moves the passed grant to the constructed node
1949-
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool fAddnode)
1930+
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
19501931
{
19511932
//
19521933
// Initiate outbound network connection
@@ -1975,8 +1956,8 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
19751956
pnode->fOneShot = true;
19761957
if (fFeeler)
19771958
pnode->fFeeler = true;
1978-
if (fAddnode)
1979-
pnode->fAddnode = true;
1959+
if (manual_connection)
1960+
pnode->m_manual_connection = true;
19801961

19811962
m_msgproc->InitializeNode(pnode);
19821963
{
@@ -2712,7 +2693,6 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
27122693
nSendVersion(0)
27132694
{
27142695
nServices = NODE_NONE;
2715-
nServicesExpected = NODE_NONE;
27162696
hSocket = hSocketIn;
27172697
nRecvVersion = INIT_PROTO_VERSION;
27182698
nLastSend = 0;
@@ -2725,7 +2705,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
27252705
strSubVer = "";
27262706
fWhitelisted = false;
27272707
fOneShot = false;
2728-
fAddnode = false;
2708+
m_manual_connection = false;
27292709
fClient = false; // set by version message
27302710
fFeeler = false;
27312711
fSuccessfullyConnected = false;

src/net.h

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

87-
static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;
88-
8987
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
9088
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
9189

@@ -130,7 +128,6 @@ class CConnman
130128
struct Options
131129
{
132130
ServiceFlags nLocalServices = NODE_NONE;
133-
ServiceFlags nRelevantServices = NODE_NONE;
134131
int nMaxConnections = 0;
135132
int nMaxOutbound = 0;
136133
int nMaxAddnode = 0;
@@ -152,7 +149,6 @@ class CConnman
152149

153150
void Init(const Options& connOptions) {
154151
nLocalServices = connOptions.nLocalServices;
155-
nRelevantServices = connOptions.nRelevantServices;
156152
nMaxConnections = connOptions.nMaxConnections;
157153
nMaxOutbound = std::min(connOptions.nMaxOutbound, connOptions.nMaxConnections);
158154
nMaxAddnode = connOptions.nMaxAddnode;
@@ -175,7 +171,7 @@ class CConnman
175171
void Interrupt();
176172
bool GetNetworkActive() const { return fNetworkActive; };
177173
void SetNetworkActive(bool active);
178-
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool fAddnode = false);
174+
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
179175
bool CheckIncomingNonce(uint64_t nonce);
180176

181177
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
@@ -390,9 +386,6 @@ class CConnman
390386
/** Services this instance offers */
391387
ServiceFlags nLocalServices;
392388

393-
/** Services this instance cares about */
394-
ServiceFlags nRelevantServices;
395-
396389
CSemaphore *semOutbound;
397390
CSemaphore *semAddnode;
398391
int nMaxConnections;
@@ -513,7 +506,7 @@ class CNodeStats
513506
int nVersion;
514507
std::string cleanSubVer;
515508
bool fInbound;
516-
bool fAddnode;
509+
bool m_manual_connection;
517510
int nStartingHeight;
518511
uint64_t nSendBytes;
519512
mapMsgCmdSize mapSendBytesPerMsgCmd;
@@ -585,7 +578,6 @@ class CNode
585578
public:
586579
// socket
587580
std::atomic<ServiceFlags> nServices;
588-
ServiceFlags nServicesExpected;
589581
SOCKET hSocket;
590582
size_t nSendSize; // total size of all vSendMsg entries
591583
size_t nSendOffset; // offset inside the first vSendMsg already sent
@@ -623,7 +615,7 @@ class CNode
623615
bool fWhitelisted; // This peer can bypass DoS banning.
624616
bool fFeeler; // If true this node is being used as a short lived feeler.
625617
bool fOneShot;
626-
bool fAddnode;
618+
bool m_manual_connection;
627619
bool fClient;
628620
const bool fInbound;
629621
std::atomic_bool fSuccessfullyConnected;

src/net_processing.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,11 +1243,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
12431243
{
12441244
connman->SetServices(pfrom->addr, nServices);
12451245
}
1246-
if (pfrom->nServicesExpected & ~nServices)
1246+
if (!pfrom->fInbound && !pfrom->fFeeler && !pfrom->m_manual_connection && !HasAllDesirableServiceFlags(nServices))
12471247
{
1248-
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, pfrom->nServicesExpected);
1248+
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, GetDesirableServiceFlags(nServices));
12491249
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
1250-
strprintf("Expected to offer services %08x", pfrom->nServicesExpected)));
1250+
strprintf("Expected to offer services %08x", GetDesirableServiceFlags(nServices))));
12511251
pfrom->fDisconnect = true;
12521252
return false;
12531253
}
@@ -1466,7 +1466,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
14661466
if (interruptMsgProc)
14671467
return true;
14681468

1469-
if ((addr.nServices & REQUIRED_SERVICES) != REQUIRED_SERVICES)
1469+
// We only bother storing full nodes, though this may include
1470+
// things which we would not make an outbound connection to, in
1471+
// part because we may make feeler connections to them.
1472+
if (!MayHaveUsefulAddressDB(addr.nServices))
14701473
continue;
14711474

14721475
if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
@@ -2642,8 +2645,8 @@ static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman)
26422645
state.fShouldBan = false;
26432646
if (pnode->fWhitelisted)
26442647
LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString());
2645-
else if (pnode->fAddnode)
2646-
LogPrintf("Warning: not punishing addnoded peer %s!\n", pnode->addr.ToString());
2648+
else if (pnode->m_manual_connection)
2649+
LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode->addr.ToString());
26472650
else {
26482651
pnode->fDisconnect = true;
26492652
if (pnode->addr.IsLocal())

src/protocol.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,43 @@ enum ServiceFlags : uint64_t {
277277
// BIP process.
278278
};
279279

280+
/**
281+
* Gets the set of service flags which are "desirable" for a given peer.
282+
*
283+
* These are the flags which are required for a peer to support for them
284+
* to be "interesting" to us, ie for us to wish to use one of our few
285+
* outbound connection slots for or for us to wish to prioritize keeping
286+
* their connection around.
287+
*
288+
* Relevant service flags may be peer- and state-specific in that the
289+
* version of the peer may determine which flags are required (eg in the
290+
* case of NODE_NETWORK_LIMITED where we seek out NODE_NETWORK peers
291+
* unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which
292+
* case NODE_NETWORK_LIMITED suffices).
293+
*
294+
* Thus, generally, avoid calling with peerServices == NODE_NONE.
295+
*/
296+
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
297+
return ServiceFlags(NODE_NETWORK | NODE_WITNESS);
298+
}
299+
300+
/**
301+
* A shortcut for (services & GetDesirableServiceFlags(services))
302+
* == GetDesirableServiceFlags(services), ie determines whether the given
303+
* set of service flags are sufficient for a peer to be "relevant".
304+
*/
305+
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) {
306+
return !(GetDesirableServiceFlags(services) & (~services));
307+
}
308+
309+
/**
310+
* Checks if a peer with the given service flags may be capable of having a
311+
* robust address-storage DB. Currently an alias for checking NODE_NETWORK.
312+
*/
313+
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) {
314+
return services & NODE_NETWORK;
315+
}
316+
280317
/** A CService with information about it as peer */
281318
class CAddress : public CService
282319
{

src/rpc/net.cpp

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

0 commit comments

Comments
 (0)