Bitcoin
Namespaces | Functions | Variables
protocol.cpp File Reference
#include <protocol.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <arpa/inet.h>

Namespaces

 NetMsgType
 

Functions

static std::atomic< bool > g_initial_block_download_completed (false)
 
static const std::vector< std::string > allNetMessageTypesVec (allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes))
 
ServiceFlags GetDesirableServiceFlags (ServiceFlags services)
 
void SetServiceFlagsIBDCache (bool state)
 
bool operator< (const CInv &a, const CInv &b)
 
const std::vector< std::string > & getAllNetMessageTypes ()
 

Variables

const char * NetMsgType::VERSION ="version"
 
const char * NetMsgType::VERACK ="verack"
 
const char * NetMsgType::ADDR ="addr"
 
const char * NetMsgType::INV ="inv"
 
const char * NetMsgType::GETDATA ="getdata"
 
const char * NetMsgType::MERKLEBLOCK ="merkleblock"
 
const char * NetMsgType::GETBLOCKS ="getblocks"
 
const char * NetMsgType::GETHEADERS ="getheaders"
 
const char * NetMsgType::TX ="tx"
 
const char * NetMsgType::HEADERS ="headers"
 
const char * NetMsgType::BLOCK ="block"
 
const char * NetMsgType::GETADDR ="getaddr"
 
const char * NetMsgType::MEMPOOL ="mempool"
 
const char * NetMsgType::PING ="ping"
 
const char * NetMsgType::PONG ="pong"
 
const char * NetMsgType::NOTFOUND ="notfound"
 
const char * NetMsgType::FILTERLOAD ="filterload"
 
const char * NetMsgType::FILTERADD ="filteradd"
 
const char * NetMsgType::FILTERCLEAR ="filterclear"
 
const char * NetMsgType::REJECT ="reject"
 
const char * NetMsgType::SENDHEADERS ="sendheaders"
 
const char * NetMsgType::FEEFILTER ="feefilter"
 
const char * NetMsgType::SENDCMPCT ="sendcmpct"
 
const char * NetMsgType::CMPCTBLOCK ="cmpctblock"
 
const char * NetMsgType::GETBLOCKTXN ="getblocktxn"
 
const char * NetMsgType::BLOCKTXN ="blocktxn"
 
static const std::string allNetMessageTypes []
 

Function Documentation

◆ allNetMessageTypesVec()

static const std::vector<std::string> allNetMessageTypesVec ( allNetMessageTypes  ,
allNetMessageTypes ARRAYLENallNetMessageTypes 
)
static

◆ g_initial_block_download_completed()

static std::atomic<bool> g_initial_block_download_completed ( false  )
static

◆ getAllNetMessageTypes()

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

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

◆ operator<()

bool operator< ( const CInv a,
const CInv b 
)

◆ SetServiceFlagsIBDCache()

void SetServiceFlagsIBDCache ( bool  status)

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

Variable Documentation

◆ allNetMessageTypes

const std::string allNetMessageTypes[]
static
Initial value:
= {
}
const char * ADDR
Definition: protocol.cpp:20
const char * VERACK
Definition: protocol.cpp:19
const char * GETBLOCKTXN
Definition: protocol.cpp:42
const char * NOTFOUND
Definition: protocol.cpp:33
const char * BLOCK
Definition: protocol.cpp:28
const char * INV
Definition: protocol.cpp:21
const char * SENDCMPCT
Definition: protocol.cpp:40
const char * MEMPOOL
Definition: protocol.cpp:30
const char * TX
Definition: protocol.cpp:26
const char * HEADERS
Definition: protocol.cpp:27
const char * FILTERLOAD
Definition: protocol.cpp:34
const char * FILTERADD
Definition: protocol.cpp:35
const char * GETBLOCKS
Definition: protocol.cpp:24
const char * REJECT
Definition: protocol.cpp:37
const char * SENDHEADERS
Definition: protocol.cpp:38
const char * GETDATA
Definition: protocol.cpp:22
const char * FILTERCLEAR
Definition: protocol.cpp:36
const char * PONG
Definition: protocol.cpp:32
const char * VERSION
Definition: protocol.cpp:18
const char * GETHEADERS
Definition: protocol.cpp:25
const char * GETADDR
Definition: protocol.cpp:29
const char * BLOCKTXN
Definition: protocol.cpp:43
const char * PING
Definition: protocol.cpp:31
const char * CMPCTBLOCK
Definition: protocol.cpp:41
const char * MERKLEBLOCK
Definition: protocol.cpp:23
const char * FEEFILTER
Definition: protocol.cpp:39

All known message types. Keep this in the same order as the list of messages above and in protocol.h.