Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.h
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | enum ServiceFlags : uint64_t { | ||||
// do not actually support. Other service bits should be allocated via the | // do not actually support. Other service bits should be allocated via the | ||||
// BIP process. | // BIP process. | ||||
// NODE_AVALANCHE means the node supports Bitcoin Cash's avalanche | // NODE_AVALANCHE means the node supports Bitcoin Cash's avalanche | ||||
// preconsensus mechanism. | // preconsensus mechanism. | ||||
NODE_AVALANCHE = (1 << 24), | NODE_AVALANCHE = (1 << 24), | ||||
}; | }; | ||||
extern std::atomic<bool> g_initial_block_download_completed; | |||||
/** | /** | ||||
* Gets the set of service flags which are "desirable" for a given peer. | * Gets the set of service flags which are "desirable" for a given peer. | ||||
* | * | ||||
* These are the flags which are required for a peer to support for them | * These are the flags which are required for a peer to support for them | ||||
* to be "interesting" to us, ie for us to wish to use one of our few | * to be "interesting" to us, ie for us to wish to use one of our few | ||||
* outbound connection slots for or for us to wish to prioritize keeping | * outbound connection slots for or for us to wish to prioritize keeping | ||||
* their connection around. | * their connection around. | ||||
* | * | ||||
* Relevant service flags may be peer- and state-specific in that the | * Relevant service flags may be peer- and state-specific in that the | ||||
* version of the peer may determine which flags are required (eg in the | * version of the peer may determine which flags are required (eg in the | ||||
* case of NODE_NETWORK_LIMITED where we seek out NODE_NETWORK peers | * case of NODE_NETWORK_LIMITED where we seek out NODE_NETWORK peers | ||||
* unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which | * unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which | ||||
* case NODE_NETWORK_LIMITED suffices). | * case NODE_NETWORK_LIMITED suffices). | ||||
* | * | ||||
* Thus, generally, avoid calling with peerServices == NODE_NONE, unless | * Thus, generally, avoid calling with peerServices == NODE_NONE, unless | ||||
* state-specific flags must absolutely be avoided. When called with | * state-specific flags must absolutely be avoided. When called with | ||||
* peerServices == NODE_NONE, the returned desirable service flags are | * peerServices == NODE_NONE, the returned desirable service flags are | ||||
* guaranteed to not change dependant on state - ie they are suitable for | * guaranteed to not change dependant on state - ie they are suitable for | ||||
* use when describing peers which we know to be desirable, but for which | * use when describing peers which we know to be desirable, but for which | ||||
* we do not have a confirmed set of service flags. | * we do not have a confirmed set of service flags. | ||||
* | * | ||||
* If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py | * If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py | ||||
* should be updated appropriately to filter for the same nodes. | * should be updated appropriately to filter for the same nodes. | ||||
*/ | */ | ||||
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) { | ServiceFlags GetDesirableServiceFlags(ServiceFlags services); | ||||
if ((services & NODE_NETWORK_LIMITED) && | |||||
g_initial_block_download_completed) { | /** | ||||
return ServiceFlags(NODE_NETWORK_LIMITED); | * Set the current IBD status in order to figure out the desirable service | ||||
} | * flags | ||||
return ServiceFlags(NODE_NETWORK); | */ | ||||
} | void SetServiceFlagsIBDCache(bool status); | ||||
/** | /** | ||||
* A shortcut for (services & GetDesirableServiceFlags(services)) | * A shortcut for (services & GetDesirableServiceFlags(services)) | ||||
* == GetDesirableServiceFlags(services), ie determines whether the given | * == GetDesirableServiceFlags(services), ie determines whether the given | ||||
* set of service flags are sufficient for a peer to be "relevant". | * set of service flags are sufficient for a peer to be "relevant". | ||||
*/ | */ | ||||
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) { | static inline bool HasAllDesirableServiceFlags(ServiceFlags services) { | ||||
return !(GetDesirableServiceFlags(services) & (~services)); | return !(GetDesirableServiceFlags(services) & (~services)); | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |