Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
protocol.cpp File Reference
#include <protocol.h>
#include <chainparams.h>
#include <common/system.h>
#include <config.h>
#include <logging.h>
#include <atomic>
Include dependency graph for protocol.cpp:

Go to the source code of this file.

Namespaces

namespace  NetMsgType
 Bitcoin protocol message types.
 

Functions

static std::atomic< boolg_initial_block_download_completed (false)
 
bool NetMsgType::IsBlockLike (const std::string &strCommand)
 Indicate if the message is used to transmit the content of a block.
 
static const std::vector< std::string > allNetMessageTypesVec (std::begin(allNetMessageTypes), std::end(allNetMessageTypes))
 
static bool CheckHeaderMagicAndCommand (const CMessageHeader &header, const CMessageHeader::MessageMagic &magic)
 
ServiceFlags GetDesirableServiceFlags (ServiceFlags services)
 Gets the set of service flags which are "desirable" for a given peer.
 
void SetServiceFlagsIBDCache (bool state)
 Set the current IBD status in order to figure out the desirable service flags.
 
const std::vector< std::string > & getAllNetMessageTypes ()
 Get a vector of all valid message types (see above)
 
static std::string serviceFlagToStr (const size_t bit)
 Convert a service flag (NODE_*) to a human readable string.
 
std::vector< std::string > serviceFlagsToStr (const uint64_t flags)
 Convert service flags (a bitmask of NODE_*) to human readable strings.
 

Variables

const charNetMsgType::VERSION = "version"
 The version message provides information about the transmitting node to the receiving node at the beginning of a connection.
 
const charNetMsgType::VERACK = "verack"
 The verack message acknowledges a previously-received version message, informing the connecting node that it can begin to send other messages.
 
const charNetMsgType::ADDR = "addr"
 The addr (IP address) message relays connection information for peers on the network.
 
const charNetMsgType::ADDRV2 = "addrv2"
 The addrv2 message relays connection information for peers on the network just like the addr message, but is extended to allow gossiping of longer node addresses (see BIP155).
 
const charNetMsgType::SENDADDRV2 = "sendaddrv2"
 The sendaddrv2 message signals support for receiving ADDRV2 messages (BIP155).
 
const charNetMsgType::INV = "inv"
 The inv message (inventory message) transmits one or more inventories of objects known to the transmitting peer.
 
const charNetMsgType::GETDATA = "getdata"
 The getdata message requests one or more data objects from another node.
 
const charNetMsgType::MERKLEBLOCK = "merkleblock"
 The merkleblock message is a reply to a getdata message which requested a block using the inventory type MSG_MERKLEBLOCK.
 
const charNetMsgType::GETBLOCKS = "getblocks"
 The getblocks message requests an inv message that provides block header hashes starting from a particular point in the block chain.
 
const charNetMsgType::GETHEADERS = "getheaders"
 The getheaders message requests a headers message that provides block headers starting from a particular point in the block chain.
 
const charNetMsgType::TX = "tx"
 The tx message transmits a single transaction.
 
const charNetMsgType::HEADERS = "headers"
 The headers message sends one or more block headers to a node which previously requested certain headers with a getheaders message.
 
const charNetMsgType::BLOCK = "block"
 The block message transmits a single serialized block.
 
const charNetMsgType::GETADDR = "getaddr"
 The getaddr message requests an addr message from the receiving node, preferably one with lots of IP addresses of other receiving nodes.
 
const charNetMsgType::MEMPOOL = "mempool"
 The mempool message requests the TXIDs of transactions that the receiving node has verified as valid but which have not yet appeared in a block.
 
const charNetMsgType::PING = "ping"
 The ping message is sent periodically to help confirm that the receiving peer is still connected.
 
const charNetMsgType::PONG = "pong"
 The pong message replies to a ping message, proving to the pinging node that the ponging node is still alive.
 
const charNetMsgType::NOTFOUND = "notfound"
 The notfound message is a reply to a getdata message which requested an object the receiving node does not have available for relay.
 
const charNetMsgType::FILTERLOAD = "filterload"
 The filterload message tells the receiving peer to filter all relayed transactions and requested merkle blocks through the provided filter.
 
const charNetMsgType::FILTERADD = "filteradd"
 The filteradd message tells the receiving peer to add a single element to a previously-set bloom filter, such as a new public key.
 
const charNetMsgType::FILTERCLEAR = "filterclear"
 The filterclear message tells the receiving peer to remove a previously-set bloom filter.
 
const charNetMsgType::SENDHEADERS = "sendheaders"
 Indicates that a node prefers to receive new block announcements via a "headers" message rather than an "inv".
 
const charNetMsgType::FEEFILTER = "feefilter"
 The feefilter message tells the receiving peer not to inv us any txs which do not meet the specified min fee rate.
 
const charNetMsgType::SENDCMPCT = "sendcmpct"
 Contains a 1-byte bool and 8-byte LE version number.
 
const charNetMsgType::CMPCTBLOCK = "cmpctblock"
 Contains a CBlockHeaderAndShortTxIDs object - providing a header and list of "short txids".
 
const charNetMsgType::GETBLOCKTXN = "getblocktxn"
 Contains a BlockTransactionsRequest Peer should respond with "blocktxn" message.
 
const charNetMsgType::BLOCKTXN = "blocktxn"
 Contains a BlockTransactions.
 
const charNetMsgType::GETCFILTERS = "getcfilters"
 getcfilters requests compact filters for a range of blocks.
 
const charNetMsgType::CFILTER = "cfilter"
 cfilter is a response to a getcfilters request containing a single compact filter.
 
const charNetMsgType::GETCFHEADERS = "getcfheaders"
 getcfheaders requests a compact filter header and the filter hashes for a range of blocks, which can then be used to reconstruct the filter headers for those blocks.
 
const charNetMsgType::CFHEADERS = "cfheaders"
 cfheaders is a response to a getcfheaders request containing a filter header and a vector of filter hashes for each subsequent block in the requested range.
 
const charNetMsgType::GETCFCHECKPT = "getcfcheckpt"
 getcfcheckpt requests evenly spaced compact filter headers, enabling parallelized download and validation of the headers between them.
 
const charNetMsgType::CFCHECKPT = "cfcheckpt"
 cfcheckpt is a response to a getcfcheckpt request containing a vector of evenly spaced filter headers for blocks on the requested chain.
 
const charNetMsgType::AVAHELLO = "avahello"
 Contains a delegation and a signature.
 
const charNetMsgType::AVAPOLL = "avapoll"
 Contains an avalanche::Poll.
 
const charNetMsgType::AVARESPONSE = "avaresponse"
 Contains an avalanche::Response.
 
const charNetMsgType::AVAPROOF = "avaproof"
 Contains an avalanche::Proof.
 
const charNetMsgType::GETAVAADDR = "getavaaddr"
 The getavaaddr message requests an addr message from the receiving node, containing IP addresses of the most active avalanche nodes.
 
const charNetMsgType::GETAVAPROOFS = "getavaproofs"
 The getavaproofs message requests an avaproofs message that provides the proof short ids of all the valid proofs known by our peer.
 
const charNetMsgType::AVAPROOFS = "avaproofs"
 The avaproofs message the proof short ids of all the valid proofs that we know.
 
const charNetMsgType::AVAPROOFSREQ = "avaproofsreq"
 Request for missing avalanche proofs after an avaproofs message has been processed.
 
static const std::string allNetMessageTypes []
 All known message types.
 

Function Documentation

◆ allNetMessageTypesVec()

static const std::vector< std::string > allNetMessageTypesVec ( std::begin(allNetMessageTypes ,
std::end(allNetMessageTypes  
)
static
Here is the caller graph for this function:

◆ CheckHeaderMagicAndCommand()

static bool CheckHeaderMagicAndCommand ( const CMessageHeader header,
const CMessageHeader::MessageMagic magic 
)
static

Definition at line 126 of file protocol.cpp.

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

◆ g_initial_block_download_completed()

static std::atomic< bool > g_initial_block_download_completed ( false  )
static
Here is the caller graph for this function:

◆ 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:

◆ 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:

◆ serviceFlagToStr()

static std::string serviceFlagToStr ( const size_t  bit)
static

Convert a service flag (NODE_*) to a human readable string.

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

Parameters
[in]bitthe service flag is calculated as (1 << bit)

Definition at line 256 of file protocol.cpp.

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

◆ SetServiceFlagsIBDCache()

void SetServiceFlagsIBDCache ( bool  state)

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

◆ allNetMessageTypes

const std::string allNetMessageTypes[]
static
Initial value:
= {
}
const char * FILTERLOAD
The filterload message tells the receiving peer to filter all relayed transactions and requested merk...
Definition protocol.cpp:36
const char * CFHEADERS
cfheaders is a response to a getcfheaders request containing a filter header and a vector of filter h...
Definition protocol.cpp:48
const char * AVAPROOFSREQ
Request for missing avalanche proofs after an avaproofs message has been processed.
Definition protocol.cpp:58
const char * CFILTER
cfilter is a response to a getcfilters request containing a single compact filter.
Definition protocol.cpp:46
const char * BLOCK
The block message transmits a single serialized block.
Definition protocol.cpp:30
const char * FILTERCLEAR
The filterclear message tells the receiving peer to remove a previously-set bloom filter.
Definition protocol.cpp:38
const char * HEADERS
The headers message sends one or more block headers to a node which previously requested certain head...
Definition protocol.cpp:29
const char * ADDRV2
The addrv2 message relays connection information for peers on the network just like the addr message,...
Definition protocol.cpp:21
const char * SENDHEADERS
Indicates that a node prefers to receive new block announcements via a "headers" message rather than ...
Definition protocol.cpp:39
const char * AVAPROOFS
The avaproofs message the proof short ids of all the valid proofs that we know.
Definition protocol.cpp:57
const char * PONG
The pong message replies to a ping message, proving to the pinging node that the ponging node is stil...
Definition protocol.cpp:34
const char * GETAVAPROOFS
The getavaproofs message requests an avaproofs message that provides the proof short ids of all the v...
Definition protocol.cpp:56
const char * SENDCMPCT
Contains a 1-byte bool and 8-byte LE version number.
Definition protocol.cpp:41
const char * GETADDR
The getaddr message requests an addr message from the receiving node, preferably one with lots of IP ...
Definition protocol.cpp:31
const char * GETCFCHECKPT
getcfcheckpt requests evenly spaced compact filter headers, enabling parallelized download and valida...
Definition protocol.cpp:49
const char * NOTFOUND
The notfound message is a reply to a getdata message which requested an object the receiving node doe...
Definition protocol.cpp:35
const char * GETAVAADDR
The getavaaddr message requests an addr message from the receiving node, containing IP addresses of t...
Definition protocol.cpp:55
const char * CMPCTBLOCK
Contains a CBlockHeaderAndShortTxIDs object - providing a header and list of "short txids".
Definition protocol.cpp:42
const char * MEMPOOL
The mempool message requests the TXIDs of transactions that the receiving node has verified as valid ...
Definition protocol.cpp:32
const char * GETCFILTERS
getcfilters requests compact filters for a range of blocks.
Definition protocol.cpp:45
const char * TX
The tx message transmits a single transaction.
Definition protocol.cpp:28
const char * AVAHELLO
Contains a delegation and a signature.
Definition protocol.cpp:51
const char * FILTERADD
The filteradd message tells the receiving peer to add a single element to a previously-set bloom filt...
Definition protocol.cpp:37
const char * ADDR
The addr (IP address) message relays connection information for peers on the network.
Definition protocol.cpp:20
const char * VERSION
The version message provides information about the transmitting node to the receiving node at the beg...
Definition protocol.cpp:18
const char * GETBLOCKS
The getblocks message requests an inv message that provides block header hashes starting from a parti...
Definition protocol.cpp:26
const char * FEEFILTER
The feefilter message tells the receiving peer not to inv us any txs which do not meet the specified ...
Definition protocol.cpp:40
const char * GETHEADERS
The getheaders message requests a headers message that provides block headers starting from a particu...
Definition protocol.cpp:27
const char * AVARESPONSE
Contains an avalanche::Response.
Definition protocol.cpp:53
const char * GETDATA
The getdata message requests one or more data objects from another node.
Definition protocol.cpp:24
const char * VERACK
The verack message acknowledges a previously-received version message, informing the connecting node ...
Definition protocol.cpp:19
const char * BLOCKTXN
Contains a BlockTransactions.
Definition protocol.cpp:44
const char * GETCFHEADERS
getcfheaders requests a compact filter header and the filter hashes for a range of blocks,...
Definition protocol.cpp:47
const char * SENDADDRV2
The sendaddrv2 message signals support for receiving ADDRV2 messages (BIP155).
Definition protocol.cpp:22
const char * PING
The ping message is sent periodically to help confirm that the receiving peer is still connected.
Definition protocol.cpp:33
const char * AVAPOLL
Contains an avalanche::Poll.
Definition protocol.cpp:52
const char * MERKLEBLOCK
The merkleblock message is a reply to a getdata message which requested a block using the inventory t...
Definition protocol.cpp:25
const char * AVAPROOF
Contains an avalanche::Proof.
Definition protocol.cpp:54
const char * CFCHECKPT
cfcheckpt is a response to a getcfcheckpt request containing a vector of evenly spaced filter headers...
Definition protocol.cpp:50
const char * GETBLOCKTXN
Contains a BlockTransactionsRequest Peer should respond with "blocktxn" message.
Definition protocol.cpp:43
const char * INV
The inv message (inventory message) transmits one or more inventories of objects known to the transmi...
Definition protocol.cpp:23

All known message types.

Keep this in the same order as the list of messages above and in protocol.h.

Definition at line 71 of file protocol.cpp.