mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 23:50:00 +01:00
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.
This commit is contained in:
@@ -84,8 +84,6 @@ static const bool DEFAULT_FORCEDNSSEED = false;
|
||||
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
|
||||
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
|
||||
|
||||
static const ServiceFlags REQUIRED_SERVICES = NODE_NETWORK;
|
||||
|
||||
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
|
||||
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
|
||||
|
||||
@@ -130,7 +128,6 @@ public:
|
||||
struct Options
|
||||
{
|
||||
ServiceFlags nLocalServices = NODE_NONE;
|
||||
ServiceFlags nRelevantServices = NODE_NONE;
|
||||
int nMaxConnections = 0;
|
||||
int nMaxOutbound = 0;
|
||||
int nMaxAddnode = 0;
|
||||
@@ -152,7 +149,6 @@ public:
|
||||
|
||||
void Init(const Options& connOptions) {
|
||||
nLocalServices = connOptions.nLocalServices;
|
||||
nRelevantServices = connOptions.nRelevantServices;
|
||||
nMaxConnections = connOptions.nMaxConnections;
|
||||
nMaxOutbound = std::min(connOptions.nMaxOutbound, connOptions.nMaxConnections);
|
||||
nMaxAddnode = connOptions.nMaxAddnode;
|
||||
@@ -390,9 +386,6 @@ private:
|
||||
/** Services this instance offers */
|
||||
ServiceFlags nLocalServices;
|
||||
|
||||
/** Services this instance cares about */
|
||||
ServiceFlags nRelevantServices;
|
||||
|
||||
CSemaphore *semOutbound;
|
||||
CSemaphore *semAddnode;
|
||||
int nMaxConnections;
|
||||
@@ -585,7 +578,6 @@ class CNode
|
||||
public:
|
||||
// socket
|
||||
std::atomic<ServiceFlags> nServices;
|
||||
ServiceFlags nServicesExpected;
|
||||
SOCKET hSocket;
|
||||
size_t nSendSize; // total size of all vSendMsg entries
|
||||
size_t nSendOffset; // offset inside the first vSendMsg already sent
|
||||
|
||||
Reference in New Issue
Block a user