Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
protocol.h File Reference
#include <netaddress.h>
#include <serialize.h>
#include <streams.h>
#include <uint256.h>
#include <util/time.h>
#include <array>
#include <cstdint>
#include <string>
Include dependency graph for protocol.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CMessageHeader
 Message header. More...
 
class  CAddress
 A CService with information about it as peer. More...
 
class  CInv
 Inv(ventory) message data. More...
 

Namespaces

namespace  NetMsgType
 Bitcoin protocol message types.
 

Enumerations

enum  ServiceFlags : uint64_t {
  NODE_NONE = 0 , NODE_NETWORK = (1 << 0) , NODE_GETUTXO = (1 << 1) , NODE_BLOOM = (1 << 2) ,
  NODE_COMPACT_FILTERS = (1 << 6) , NODE_NETWORK_LIMITED = (1 << 10) , NODE_LAST_NON_EXPERIMENTAL_SERVICE_BIT = (1 << 23) , NODE_AVALANCHE = (1 << 24)
}
 nServices flags. More...
 
enum  GetDataMsg {
  UNDEFINED = 0 , MSG_TX = 1 , MSG_BLOCK = 2 , MSG_FILTERED_BLOCK = 3 ,
  MSG_CMPCT_BLOCK = 4 , MSG_AVA_PROOF = 0x1f000001 , MSG_AVA_STAKE_CONTENDER = 0x1f000002
}
 getdata / inv message types. More...
 

Functions

bool NetMsgType::IsBlockLike (const std::string &strCommand)
 Indicate if the message is used to transmit the content of a block.
 
const std::vector< std::string > & getAllNetMessageTypes ()
 Get a vector of all valid message types (see above)
 
std::vector< std::string > serviceFlagsToStr (const uint64_t flags)
 Convert service flags (a bitmask of NODE_*) to human readable strings.
 
ServiceFlags GetDesirableServiceFlags (ServiceFlags services)
 Gets the set of service flags which are "desirable" for a given peer.
 
void SetServiceFlagsIBDCache (bool status)
 Set the current IBD status in order to figure out the desirable service flags.
 
static bool HasAllDesirableServiceFlags (ServiceFlags services)
 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 bool MayHaveUsefulAddressDB (ServiceFlags services)
 Checks if a peer with the given service flags may be capable of having a robust address-storage DB.
 

Variables

static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024
 Maximum length of incoming protocol messages (Currently 2MB).
 
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 3
 getdata message type flags
 

Enumeration Type Documentation

◆ GetDataMsg

getdata / inv message types.

These numbers are defined by the protocol. When adding a new value, be sure to mention it in the respective BIP.

Enumerator
UNDEFINED 
MSG_TX 
MSG_BLOCK 
MSG_FILTERED_BLOCK 

Defined in BIP37.

MSG_CMPCT_BLOCK 

Defined in BIP152.

MSG_AVA_PROOF 
MSG_AVA_STAKE_CONTENDER 

Definition at line 563 of file protocol.h.

◆ ServiceFlags

nServices flags.

Enumerator
NODE_NONE 
NODE_NETWORK 
NODE_GETUTXO 
NODE_BLOOM 
NODE_COMPACT_FILTERS 
NODE_NETWORK_LIMITED 
NODE_LAST_NON_EXPERIMENTAL_SERVICE_BIT 
NODE_AVALANCHE 

Definition at line 335 of file protocol.h.

Function Documentation

◆ getAllNetMessageTypes()

const std::vector< std::string > & getAllNetMessageTypes ( )

Get a vector of all valid message types (see above)

Definition at line 247 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDesirableServiceFlags()

ServiceFlags GetDesirableServiceFlags ( ServiceFlags  services)

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, unless state-specific flags must absolutely be avoided. When called with peerServices == NODE_NONE, the returned desirable service flags are guaranteed to not change dependent on state - ie they are suitable for use when describing peers which we know to be desirable, but for which we do not have a confirmed set of service flags.

If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py should be updated appropriately to filter for the same nodes.

Definition at line 204 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasAllDesirableServiceFlags()

static bool HasAllDesirableServiceFlags ( ServiceFlags  services)
inlinestatic

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".

Definition at line 427 of file protocol.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MayHaveUsefulAddressDB()

static bool MayHaveUsefulAddressDB ( ServiceFlags  services)
inlinestatic

Checks if a peer with the given service flags may be capable of having a robust address-storage DB.

Definition at line 435 of file protocol.h.

Here is the caller graph for this function:

◆ serviceFlagsToStr()

std::vector< std::string > serviceFlagsToStr ( const uint64_t  flags)

Convert service flags (a bitmask of NODE_*) to human readable strings.

It supports unknown service flags which will be returned as "UNKNOWN[...]".

Parameters
[in]flagsmultiple NODE_* bitwise-OR-ed together

Definition at line 284 of file protocol.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetServiceFlagsIBDCache()

void SetServiceFlagsIBDCache ( bool  status)

Set the current IBD status in order to figure out the desirable service flags.

Definition at line 212 of file protocol.cpp.

Here is the call graph for this function:

Variable Documentation

◆ MAX_PROTOCOL_MESSAGE_LENGTH

const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024
static

Maximum length of incoming protocol messages (Currently 2MB).

NB: Messages propagating block content are not subject to this limit.

Definition at line 25 of file protocol.h.

◆ MSG_TYPE_MASK

const uint32_t MSG_TYPE_MASK = 0xffffffff >> 3

getdata message type flags

Definition at line 556 of file protocol.h.