Bitcoin Core  27.99.0
P2P Digital Currency
Classes | Namespaces | Enumerations | Functions | Variables
protocol.h File Reference
#include <kernel/messagestartchars.h>
#include <netaddress.h>
#include <primitives/transaction.h>
#include <serialize.h>
#include <streams.h>
#include <uint256.h>
#include <util/time.h>
#include <array>
#include <cstdint>
#include <limits>
#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...
 
struct  CAddress::SerParams
 
class  CInv
 inv message data More...
 

Namespaces

 NetMsgType
 Bitcoin protocol message types.
 

Enumerations

enum  ServiceFlags : uint64_t {
  NODE_NONE = 0 , NODE_NETWORK = (1 << 0) , NODE_BLOOM = (1 << 2) , NODE_WITNESS = (1 << 3) ,
  NODE_COMPACT_FILTERS = (1 << 6) , NODE_NETWORK_LIMITED = (1 << 10) , NODE_P2P_V2 = (1 << 11)
}
 nServices flags More...
 
enum  GetDataMsg : uint32_t {
  UNDEFINED = 0 , MSG_TX = 1 , MSG_BLOCK = 2 , MSG_WTX = 5 ,
  MSG_FILTERED_BLOCK = 3 , MSG_CMPCT_BLOCK = 4 , MSG_WITNESS_BLOCK = MSG_BLOCK | MSG_WITNESS_FLAG , MSG_WITNESS_TX = MSG_TX | MSG_WITNESS_FLAG
}
 getdata / inv message types. More...
 

Functions

const std::vector< std::string > & getAllNetMessageTypes ()
 
std::vector< std::string > serviceFlagsToStr (uint64_t flags)
 Convert service flags (a bitmask of NODE_*) to human readable strings. More...
 
constexpr ServiceFlags SeedsServiceFlags ()
 State independent service flags. More...
 
static bool MayHaveUsefulAddressDB (ServiceFlags services)
 Checks if a peer with the given service flags may be capable of having a robust address-storage DB. More...
 
GenTxid ToGenTxid (const CInv &inv)
 Convert a TX/WITNESS_TX/WTX CInv to a GenTxid. More...
 

Variables

const uint32_t MSG_WITNESS_FLAG = 1 << 30
 getdata message type flags More...
 
const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2
 

Enumeration Type Documentation

◆ GetDataMsg

enum GetDataMsg : uint32_t

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_WTX 

Defined in BIP 339.

MSG_FILTERED_BLOCK 

Defined in BIP37.

MSG_CMPCT_BLOCK 

Defined in BIP152.

MSG_WITNESS_BLOCK 

Defined in BIP144.

MSG_WITNESS_TX 

Defined in BIP144.

Definition at line 441 of file protocol.h.

◆ ServiceFlags

enum ServiceFlags : uint64_t

nServices flags

Enumerator
NODE_NONE 
NODE_NETWORK 
NODE_BLOOM 
NODE_WITNESS 
NODE_COMPACT_FILTERS 
NODE_NETWORK_LIMITED 
NODE_P2P_V2 

Definition at line 274 of file protocol.h.

Function Documentation

◆ getAllNetMessageTypes()

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

Definition at line 167 of file protocol.cpp.

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 325 of file protocol.h.

Here is the caller graph for this function:

◆ SeedsServiceFlags()

constexpr ServiceFlags SeedsServiceFlags ( )
constexpr

State independent service flags.

If the return value is changed, contrib/seeds/makeseeds.py should be updated appropriately to filter for nodes with desired service flags (compatible with our new flags).

Definition at line 319 of file protocol.h.

Here is the caller graph for this function:

◆ serviceFlagsToStr()

std::vector<std::string> serviceFlagsToStr ( 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 194 of file protocol.cpp.

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

◆ ToGenTxid()

GenTxid ToGenTxid ( const CInv inv)

Convert a TX/WITNESS_TX/WTX CInv to a GenTxid.

Definition at line 207 of file protocol.cpp.

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

Variable Documentation

◆ MSG_TYPE_MASK

const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2

Definition at line 435 of file protocol.h.

◆ MSG_WITNESS_FLAG

const uint32_t MSG_WITNESS_FLAG = 1 << 30

getdata message type flags

Definition at line 434 of file protocol.h.