Changeset View
Changeset View
Standalone View
Standalone View
src/protocol.h
Show First 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | enum ServiceFlags : uint64_t { | ||||
// bitcoin-development mailing list. Remember that service bits are just | // bitcoin-development mailing list. Remember that service bits are just | ||||
// unauthenticated advertisements, so your code must be robust against | // unauthenticated advertisements, so your code must be robust against | ||||
// collisions and other cases where nodes may be advertising a service they | // collisions and other cases where nodes may be advertising a service they | ||||
// 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. | ||||
}; | }; | ||||
/** | /** | ||||
* 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 | |||||
* 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 | |||||
* their connection around. | |||||
* | |||||
* 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 | |||||
* 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 | |||||
* case NODE_NETWORK_LIMITED suffices). | |||||
* | |||||
* Thus, generally, avoid calling with peerServices == NODE_NONE. | |||||
*/ | |||||
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) { | |||||
return ServiceFlags(NODE_NETWORK); | |||||
} | |||||
/** | |||||
* A shortcut for (services & GetDesirableServiceFlags(services)) | |||||
* == GetDesirableServiceFlags(services), ie determines whether the given | |||||
* set of service flags are sufficient for a peer to be "relevant". | |||||
*/ | |||||
static inline bool HasAllDesirableServiceFlags(ServiceFlags services) { | |||||
return !(GetDesirableServiceFlags(services) & (~services)); | |||||
} | |||||
/** | |||||
* Checks if a peer with the given service flags may be capable of having a | |||||
* robust address-storage DB. Currently an alias for checking NODE_NETWORK. | |||||
*/ | |||||
static inline bool MayHaveUsefulAddressDB(ServiceFlags services) { | |||||
return services & NODE_NETWORK; | |||||
} | |||||
/** | |||||
* A CService with information about it as peer. | * A CService with information about it as peer. | ||||
*/ | */ | ||||
class CAddress : public CService { | class CAddress : public CService { | ||||
public: | public: | ||||
CAddress(); | CAddress(); | ||||
explicit CAddress(CService ipIn, ServiceFlags nServicesIn); | explicit CAddress(CService ipIn, ServiceFlags nServicesIn); | ||||
void Init(); | void Init(); | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |