Bitcoin ABC  0.24.11
P2P Digital Currency
Classes | Functions | Variables
net_processing.cpp File Reference
#include <net_processing.h>
#include <addrman.h>
#include <avalanche/avalanche.h>
#include <avalanche/peermanager.h>
#include <avalanche/processor.h>
#include <avalanche/proof.h>
#include <avalanche/validation.h>
#include <banman.h>
#include <blockdb.h>
#include <blockencodings.h>
#include <blockfilter.h>
#include <blockvalidity.h>
#include <chain.h>
#include <chainparams.h>
#include <config.h>
#include <consensus/validation.h>
#include <hash.h>
#include <index/blockfilterindex.h>
#include <invrequest.h>
#include <merkleblock.h>
#include <netbase.h>
#include <netmessagemaker.h>
#include <policy/fees.h>
#include <policy/policy.h>
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <random.h>
#include <reverse_iterator.h>
#include <scheduler.h>
#include <streams.h>
#include <tinyformat.h>
#include <txmempool.h>
#include <util/check.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <validation.h>
#include <memory>
#include <typeinfo>
Include dependency graph for net_processing.cpp:

Go to the source code of this file.

Classes

struct  DataRequestParameters
 
struct  COrphanTx
 
class  CNetProcessingCleanup
 

Functions

std::map< TxId, COrphanTx > mapOrphanTransactions GUARDED_BY (g_cs_orphans)
 Map from txid to orphan transaction record. More...
 
void EraseOrphansFor (NodeId peer)
 
template<class InvId >
static bool TooManyAnnouncements (const CNode &node, const InvRequestTracker< InvId > &requestTracker, const DataRequestParameters &requestParams)
 
template<class InvId >
static std::chrono::microseconds ComputeRequestTime (const CNode &node, const InvRequestTracker< InvId > &requestTracker, const DataRequestParameters &requestParams, std::chrono::microseconds current_time, bool preferred)
 Compute the request time for this announcement, current time plus delays for: More...
 
void UpdateLastBlockAnnounceTime (NodeId node, int64_t time_in_seconds)
 
static void AddToCompactExtraTransactions (const CTransactionRef &tx) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
 
bool AddOrphanTx (const CTransactionRef &tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
 
static int EraseOrphanTx (const TxId id) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
 
unsigned int LimitOrphanTxSize (unsigned int nMaxOrphans)
 
static bool BlockRequestAllowed (const CBlockIndex *pindex, const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static std::shared_ptr< const CBlock > most_recent_block GUARDED_BY (cs_most_recent_block)
 
static bool AlreadyHaveTx (const TxId &txid, const CTxMemPool &mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool AlreadyHaveBlock (const BlockHash &block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static bool AlreadyHaveProof (const avalanche::ProofId &proofid)
 
void RelayTransaction (const TxId &txid, const CConnman &connman)
 Relay transaction to every node. More...
 
void RelayProof (const avalanche::ProofId &proofid, const CConnman &connman)
 Relay proof to every node. More...
 
static void RelayAddress (const CNode &originator, const CAddress &addr, bool fReachable, const CConnman &connman)
 Relay (gossip) an address to a few randomly chosen nodes. More...
 
static void ProcessGetBlockData (const Config &config, CNode &pfrom, Peer &peer, const CInv &inv, CConnman &connman)
 
static CTransactionRef FindTxForGetData (const CTxMemPool &mempool, const CNode &peer, const TxId &txid, const std::chrono::seconds mempool_req, const std::chrono::seconds now) LOCKS_EXCLUDED(cs_main)
 Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed). More...
 
static avalanche::ProofRef FindProofForGetData (const CNode &peer, const avalanche::ProofId &proofid, const std::chrono::seconds now)
 Determine whether or not a peer can request a proof, and return it (or nullptr if not found or not allowed). More...
 
static void ProcessGetData (const Config &config, CNode &pfrom, Peer &peer, CConnman &connman, CTxMemPool &mempool, const std::atomic< bool > &interruptMsgProc) LOCKS_EXCLUDED(
 
 AssertLockHeld (g_cs_orphans)
 
 while (!orphan_work_set.empty())
 
static bool PrepareBlockFilterRequest (CNode &peer, const CChainParams &chain_params, BlockFilterType filter_type, uint32_t start_height, const BlockHash &stop_hash, uint32_t max_height_diff, const CBlockIndex *&stop_index, BlockFilterIndex *&filter_index)
 Validation logic for compact filters request handling. More...
 
static void ProcessGetCFilters (CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman)
 Handle a cfilters request. More...
 
static void ProcessGetCFHeaders (CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman)
 Handle a cfheaders request. More...
 
static void ProcessGetCFCheckPt (CNode &peer, CDataStream &vRecv, const CChainParams &chain_params, CConnman &connman)
 Handle a getcfcheckpt request. More...
 
bool IsAvalancheMessageType (const std::string &msg_type)
 
static uint32_t getAvalancheVoteForBlock (const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Decide a response for an Avalanche poll about the given block. More...
 

Variables

static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60
 Expiration time for orphan transactions in seconds. More...
 
static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60
 Minimum time between orphan transactions expire time checks in seconds. More...
 
static constexpr auto RELAY_TX_CACHE_TIME = 15min
 How long to cache transactions in mapRelay for normal relay. More...
 
static constexpr auto UNCONDITIONAL_RELAY_DELAY = 2min
 How long a transaction has to be in the mempool before it can unconditionally be relayed (even when not in mapRelay). More...
 
static constexpr auto HEADERS_DOWNLOAD_TIMEOUT_BASE = 15min
 Headers download timeout. More...
 
static constexpr auto HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1ms
 
static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4
 Protect at least this many outbound peers from disconnection due to slow/behind headers chain. More...
 
static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60
 Timeout for (unprotected) outbound peers to sync to our chainwork, in seconds. More...
 
static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60
 How frequently to check for stale tips, in seconds. More...
 
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45
 How frequently to check for extra outbound peers and disconnect, in seconds. More...
 
static constexpr int64_t MINIMUM_CONNECT_TIME = 30
 Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds. More...
 
static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL
 SHA256("main address relay")[0:8]. More...
 
static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60
 Age after which a stale block will no longer be served if requested as protection against fingerprinting. More...
 
static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60
 Age after which a block is considered historical for purposes of rate limiting block relay. More...
 
static constexpr std::chrono::minutes PING_INTERVAL {2}
 Time between pings automatically sent out for latency probing and keepalive. More...
 
static const unsigned int MAX_LOCATOR_SZ = 101
 The maximum number of entries in a locator. More...
 
static const unsigned int MAX_INV_SZ = 50000
 The maximum number of entries in an 'inv' protocol message. More...
 
static constexpr DataRequestParameters TX_REQUEST_PARAMS
 
static constexpr DataRequestParameters PROOF_REQUEST_PARAMS
 
static const unsigned int MAX_GETDATA_SZ = 1000
 Limit to avoid sending big packets. More...
 
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16
 Number of blocks that can be requested at any given time from a single peer. More...
 
static constexpr auto BLOCK_STALLING_TIMEOUT = 2s
 Time during which a peer must stall block download progress before being disconnected. More...
 
static const unsigned int MAX_HEADERS_RESULTS = 2000
 Number of headers sent in one getheaders result. More...
 
static const int MAX_CMPCTBLOCK_DEPTH = 5
 Maximum depth of blocks we're willing to serve as compact blocks to peers when requested. More...
 
static const int MAX_BLOCKTXN_DEPTH = 10
 Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. More...
 
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024
 Size of the "block download window": how far ahead of our current height do we fetch? Larger windows tolerate larger download speed differences between peer, but increase the potential degree of disordering of blocks on disk (which make reindexing and pruning harder). More...
 
static constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = 1
 Block download timeout base, expressed in multiples of the block interval (i.e. More...
 
static constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5
 Additional block download timeout per parallel downloading peer (i.e. More...
 
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8
 Maximum number of headers to announce when relaying blocks with headers message. More...
 
static const int MAX_UNCONNECTING_HEADERS = 10
 Maximum number of unconnecting headers announcements before DoS score. More...
 
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288
 Minimum blocks required to signal NODE_NETWORK_LIMITED. More...
 
static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24h
 Average delay between local address broadcasts. More...
 
static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL = 30s
 Average delay between peer address broadcasts. More...
 
static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL = 5s
 Average delay between trickled inventory transmissions for inbound peers. More...
 
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7
 Maximum rate of inventory items to send per second. More...
 
static constexpr unsigned int INVENTORY_BROADCAST_MAX_PER_MB
 Maximum number of inventory items to send per transmission. More...
 
static constexpr unsigned int INVENTORY_MAX_RECENT_RELAY = 3500
 The number of most recently announced transactions a peer can request. More...
 
static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL = 10min
 Verify that INVENTORY_MAX_RECENT_RELAY is enough to cache everything typically relayed before unconditional relay from the mempool kicks in. More...
 
static constexpr auto MAX_FEEFILTER_CHANGE_DELAY = 5min
 Maximum feefilter broadcast delay after significant change. More...
 
static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000
 Maximum number of compact filters that may be requested with one getcfilters. More...
 
static constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000
 Maximum number of cf hashes that may be requested with one getcfheaders. More...
 
static constexpr size_t MAX_PCT_ADDR_TO_SEND = 23
 the maximum percentage of addresses from our addrman to return in response to a getaddr message. More...
 
RecursiveMutex g_cs_orphans
 Guards orphan transactions and extra txs for compact blocks. More...
 
static RecursiveMutex cs_most_recent_block
 
static CNetProcessingCleanup instance_of_cnetprocessingcleanup
 

Function Documentation

◆ AddOrphanTx()

bool AddOrphanTx ( const CTransactionRef tx,
NodeId  peer 
)

Definition at line 1538 of file net_processing.cpp.

Here is the call graph for this function:

◆ AddToCompactExtraTransactions()

static void AddToCompactExtraTransactions ( const CTransactionRef tx)
static

Definition at line 1521 of file net_processing.cpp.

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

◆ AlreadyHaveBlock()

static bool AlreadyHaveBlock ( const BlockHash block_hash)
static

Definition at line 2117 of file net_processing.cpp.

Here is the call graph for this function:

◆ AlreadyHaveProof()

static bool AlreadyHaveProof ( const avalanche::ProofId proofid)
static

Definition at line 2122 of file net_processing.cpp.

Here is the call graph for this function:

◆ AlreadyHaveTx()

static bool AlreadyHaveTx ( const TxId txid,
const CTxMemPool mempool 
)
static

Definition at line 2088 of file net_processing.cpp.

Here is the call graph for this function:

◆ AssertLockHeld()

AssertLockHeld ( g_cs_orphans  )

◆ BlockRequestAllowed()

static bool BlockRequestAllowed ( const CBlockIndex pindex,
const Consensus::Params consensusParams 
)
static

Definition at line 1784 of file net_processing.cpp.

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

◆ ComputeRequestTime()

template<class InvId >
static std::chrono::microseconds ComputeRequestTime ( const CNode node,
const InvRequestTracker< InvId > &  requestTracker,
const DataRequestParameters requestParams,
std::chrono::microseconds  current_time,
bool  preferred 
)
static

Compute the request time for this announcement, current time plus delays for:

  • nonpref_peer_delay for announcements from non-preferred connections
  • overloaded_peer_delay for announcements from peers which have at least max_peer_request_in_flight requests in flight (and don't have PF_RELAY).

Definition at line 1221 of file net_processing.cpp.

Here is the call graph for this function:

◆ EraseOrphansFor()

void EraseOrphansFor ( NodeId  peer)

Definition at line 1607 of file net_processing.cpp.

Here is the call graph for this function:

◆ EraseOrphanTx()

static int EraseOrphanTx ( const TxId  id)
static

Definition at line 1576 of file net_processing.cpp.

Here is the caller graph for this function:

◆ FindProofForGetData()

static avalanche::ProofRef FindProofForGetData ( const CNode peer,
const avalanche::ProofId proofid,
const std::chrono::seconds  now 
)
static

Determine whether or not a peer can request a proof, and return it (or nullptr if not found or not allowed).

Definition at line 2432 of file net_processing.cpp.

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

◆ FindTxForGetData()

static CTransactionRef FindTxForGetData ( const CTxMemPool mempool,
const CNode peer,
const TxId txid,
const std::chrono::seconds  mempool_req,
const std::chrono::seconds  now 
)
static

Determine whether or not a peer can request a transaction, and return it (or nullptr if not found or not allowed).

Definition at line 2393 of file net_processing.cpp.

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

◆ getAvalancheVoteForBlock()

static uint32_t getAvalancheVoteForBlock ( const BlockHash hash)
static

Decide a response for an Avalanche poll about the given block.

Parameters
[in]hashThe hash of the block being polled for
[out]uint32_tOur current vote for the block

Definition at line 3173 of file net_processing.cpp.

Here is the call graph for this function:

◆ GUARDED_BY() [1/2]

static uint256 most_recent_block_hash GUARDED_BY ( cs_most_recent_block  )
static

◆ GUARDED_BY() [2/2]

std::map<TxId, COrphanTx> mapOrphanTransactions GUARDED_BY ( g_cs_orphans  )

Map from txid to orphan transaction record.

Limited by -maxorphantx/DEFAULT_MAX_ORPHAN_TRANSACTIONS

◆ IsAvalancheMessageType()

bool IsAvalancheMessageType ( const std::string &  msg_type)

Definition at line 3160 of file net_processing.cpp.

◆ LimitOrphanTxSize()

unsigned int LimitOrphanTxSize ( unsigned int  nMaxOrphans)

Definition at line 1624 of file net_processing.cpp.

Here is the call graph for this function:

◆ PrepareBlockFilterRequest()

static bool PrepareBlockFilterRequest ( CNode peer,
const CChainParams chain_params,
BlockFilterType  filter_type,
uint32_t  start_height,
const BlockHash stop_hash,
uint32_t  max_height_diff,
const CBlockIndex *&  stop_index,
BlockFilterIndex *&  filter_index 
)
static

Validation logic for compact filters request handling.

May disconnect from the peer in the case of a bad request.

Parameters
[in]peerThe peer that we received the request from
[in]chain_paramsChain parameters
[in]filter_typeThe filter type the request is for. Must be basic filters.
[in]start_heightThe start height for the request
[in]stop_hashThe stop_hash for the request
[in]max_height_diffThe maximum number of items permitted to request, as specified in BIP 157
[out]stop_indexThe CBlockIndex for the stop_hash block, if the request can be serviced.
[out]filter_indexThe filter index, if the request can be serviced.
Returns
True if the request can be serviced.

Definition at line 2938 of file net_processing.cpp.

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

◆ ProcessGetBlockData()

static void ProcessGetBlockData ( const Config config,
CNode pfrom,
Peer &  peer,
const CInv inv,
CConnman connman 
)
static

Definition at line 2212 of file net_processing.cpp.

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

◆ ProcessGetCFCheckPt()

static void ProcessGetCFCheckPt ( CNode peer,
CDataStream vRecv,
const CChainParams chain_params,
CConnman connman 
)
static

Handle a getcfcheckpt request.

May disconnect from the peer in the case of a bad request.

Parameters
[in]peerThe peer that we received the request from
[in]vRecvThe raw message received
[in]chain_paramsChain parameters
[in]connmanPointer to the connection manager

Definition at line 3116 of file net_processing.cpp.

Here is the call graph for this function:

◆ ProcessGetCFHeaders()

static void ProcessGetCFHeaders ( CNode peer,
CDataStream vRecv,
const CChainParams chain_params,
CConnman connman 
)
static

Handle a cfheaders request.

May disconnect from the peer in the case of a bad request.

Parameters
[in]peerThe peer that we received the request from
[in]vRecvThe raw message received
[in]chain_paramsChain parameters
[in]connmanPointer to the connection manager

Definition at line 3054 of file net_processing.cpp.

Here is the call graph for this function:

◆ ProcessGetCFilters()

static void ProcessGetCFilters ( CNode peer,
CDataStream vRecv,
const CChainParams chain_params,
CConnman connman 
)
static

Handle a cfilters request.

May disconnect from the peer in the case of a bad request.

Parameters
[in]peerThe peer that we received the request from
[in]vRecvThe raw message received
[in]chain_paramsChain parameters
[in]connmanPointer to the connection manager

Definition at line 3007 of file net_processing.cpp.

Here is the call graph for this function:

◆ ProcessGetData()

static void ProcessGetData ( const Config config,
CNode pfrom,
Peer &  peer,
CConnman connman,
CTxMemPool mempool,
const std::atomic< bool > &  interruptMsgProc 
)
static

Definition at line 2466 of file net_processing.cpp.

Here is the call graph for this function:

◆ RelayAddress()

static void RelayAddress ( const CNode originator,
const CAddress addr,
bool  fReachable,
const CConnman connman 
)
static

Relay (gossip) an address to a few randomly chosen nodes.

We choose the same nodes within a given 24h window (if the list of connected nodes does not change) and we don't relay to nodes that already know an address. So within 24h we will likely relay a given address once. This is to prevent a peer from unjustly giving their address better propagation by sending it to us repeatedly.

Parameters
[in]originatorThe peer that sent us the address. We don't want to relay it back.
[in]addrAddress to relay.
[in]fReachableWhether the address' network is reachable. We relay unreachable addresses less.
[in]connmanConnection manager to choose nodes to relay to.

Definition at line 2163 of file net_processing.cpp.

Here is the call graph for this function:

◆ RelayProof()

void RelayProof ( const avalanche::ProofId proofid,
const CConnman connman 
)

Relay proof to every node.

Definition at line 2144 of file net_processing.cpp.

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

◆ RelayTransaction()

void RelayTransaction ( const TxId txid,
const CConnman connman 
)

Relay transaction to every node.

Definition at line 2139 of file net_processing.cpp.

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

◆ TooManyAnnouncements()

template<class InvId >
static bool TooManyAnnouncements ( const CNode node,
const InvRequestTracker< InvId > &  requestTracker,
const DataRequestParameters requestParams 
)
static

Definition at line 1204 of file net_processing.cpp.

Here is the call graph for this function:

◆ UpdateLastBlockAnnounceTime()

void UpdateLastBlockAnnounceTime ( NodeId  node,
int64_t  time_in_seconds 
)

Definition at line 1316 of file net_processing.cpp.

◆ while()

while ( !orphan_work_set.  empty())

Definition at line 2867 of file net_processing.cpp.

Here is the call graph for this function:

Variable Documentation

◆ AVG_ADDRESS_BROADCAST_INTERVAL

constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL = 30s
staticconstexpr

Average delay between peer address broadcasts.

Definition at line 229 of file net_processing.cpp.

◆ AVG_FEEFILTER_BROADCAST_INTERVAL

constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL = 10min
staticconstexpr

Verify that INVENTORY_MAX_RECENT_RELAY is enough to cache everything typically relayed before unconditional relay from the mempool kicks in.

This is only a lower bound, and it should be larger to account for higher inv rate to outbound peers, and random variations in the broadcast mechanism. Average delay between feefilter broadcasts in seconds.

Definition at line 260 of file net_processing.cpp.

◆ AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL

constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24h
staticconstexpr

Average delay between local address broadcasts.

Definition at line 225 of file net_processing.cpp.

◆ BLOCK_DOWNLOAD_TIMEOUT_BASE

constexpr double BLOCK_DOWNLOAD_TIMEOUT_BASE = 1
staticconstexpr

Block download timeout base, expressed in multiples of the block interval (i.e.

10 min)

Definition at line 208 of file net_processing.cpp.

◆ BLOCK_DOWNLOAD_TIMEOUT_PER_PEER

constexpr double BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 0.5
staticconstexpr

Additional block download timeout per parallel downloading peer (i.e.

5 min)

Definition at line 212 of file net_processing.cpp.

◆ BLOCK_DOWNLOAD_WINDOW

const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024
static

Size of the "block download window": how far ahead of our current height do we fetch? Larger windows tolerate larger download speed differences between peer, but increase the potential degree of disordering of blocks on disk (which make reindexing and pruning harder).

We'll probably want to make this a per-peer adaptive value at some point.

Definition at line 203 of file net_processing.cpp.

◆ BLOCK_STALLING_TIMEOUT

constexpr auto BLOCK_STALLING_TIMEOUT = 2s
staticconstexpr

Time during which a peer must stall block download progress before being disconnected.

Definition at line 178 of file net_processing.cpp.

◆ CHAIN_SYNC_TIMEOUT

constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60
staticconstexpr

Timeout for (unprotected) outbound peers to sync to our chainwork, in seconds.

Definition at line 74 of file net_processing.cpp.

◆ cs_most_recent_block

RecursiveMutex cs_most_recent_block
static

Definition at line 1941 of file net_processing.cpp.

◆ EXTRA_PEER_CHECK_INTERVAL

constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45
staticconstexpr

How frequently to check for extra outbound peers and disconnect, in seconds.

Definition at line 81 of file net_processing.cpp.

◆ g_cs_orphans

void g_cs_orphans
Initial value:

Guards orphan transactions and extra txs for compact blocks.

Definition at line 290 of file net_processing.cpp.

◆ HEADERS_DOWNLOAD_TIMEOUT_BASE

constexpr auto HEADERS_DOWNLOAD_TIMEOUT_BASE = 15min
staticconstexpr

Headers download timeout.

Timeout = base + per_header * (expected number of headers)

Definition at line 62 of file net_processing.cpp.

◆ HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER

constexpr auto HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1ms
staticconstexpr

Definition at line 63 of file net_processing.cpp.

◆ HISTORICAL_BLOCK_AGE

constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60
staticconstexpr

Age after which a block is considered historical for purposes of rate limiting block relay.

Set to one week, denominated in seconds.

Definition at line 94 of file net_processing.cpp.

◆ INBOUND_INVENTORY_BROADCAST_INTERVAL

constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL = 5s
staticconstexpr

Average delay between trickled inventory transmissions for inbound peers.

Blocks and peers with noban permission bypass this.

Definition at line 234 of file net_processing.cpp.

◆ instance_of_cnetprocessingcleanup

CNetProcessingCleanup instance_of_cnetprocessingcleanup
static

Definition at line 6424 of file net_processing.cpp.

◆ INVENTORY_BROADCAST_MAX_PER_MB

constexpr unsigned int INVENTORY_BROADCAST_MAX_PER_MB
staticconstexpr
Initial value:

Maximum number of inventory items to send per transmission.

Definition at line 241 of file net_processing.cpp.

◆ INVENTORY_BROADCAST_PER_SECOND

constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7
staticconstexpr

Maximum rate of inventory items to send per second.

Limits the impact of low-fee transaction floods.

Definition at line 239 of file net_processing.cpp.

◆ INVENTORY_MAX_RECENT_RELAY

constexpr unsigned int INVENTORY_MAX_RECENT_RELAY = 3500
staticconstexpr

The number of most recently announced transactions a peer can request.

Definition at line 245 of file net_processing.cpp.

◆ MAX_BLOCKS_IN_TRANSIT_PER_PEER

const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16
static

Number of blocks that can be requested at any given time from a single peer.

Definition at line 173 of file net_processing.cpp.

◆ MAX_BLOCKS_TO_ANNOUNCE

const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8
static

Maximum number of headers to announce when relaying blocks with headers message.

Definition at line 217 of file net_processing.cpp.

◆ MAX_BLOCKTXN_DEPTH

const int MAX_BLOCKTXN_DEPTH = 10
static

Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for.

Definition at line 195 of file net_processing.cpp.

◆ MAX_CMPCTBLOCK_DEPTH

const int MAX_CMPCTBLOCK_DEPTH = 5
static

Maximum depth of blocks we're willing to serve as compact blocks to peers when requested.

For older blocks, a regular BLOCK response will be sent.

Definition at line 190 of file net_processing.cpp.

◆ MAX_FEEFILTER_CHANGE_DELAY

constexpr auto MAX_FEEFILTER_CHANGE_DELAY = 5min
staticconstexpr

Maximum feefilter broadcast delay after significant change.

Definition at line 264 of file net_processing.cpp.

◆ MAX_GETCFHEADERS_SIZE

constexpr uint32_t MAX_GETCFHEADERS_SIZE = 2000
staticconstexpr

Maximum number of cf hashes that may be requested with one getcfheaders.

See BIP 157.

Definition at line 274 of file net_processing.cpp.

◆ MAX_GETCFILTERS_SIZE

constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000
staticconstexpr

Maximum number of compact filters that may be requested with one getcfilters.

See BIP 157.

Definition at line 269 of file net_processing.cpp.

◆ MAX_GETDATA_SZ

const unsigned int MAX_GETDATA_SZ = 1000
static

Limit to avoid sending big packets.

Not used in processing incoming GETDATA for compatibility.

Definition at line 169 of file net_processing.cpp.

◆ MAX_HEADERS_RESULTS

const unsigned int MAX_HEADERS_RESULTS = 2000
static

Number of headers sent in one getheaders result.

We rely on the assumption that if a peer sends less than this number, we reached its tip. Changing this value is a protocol upgrade.

Definition at line 185 of file net_processing.cpp.

◆ MAX_INV_SZ

const unsigned int MAX_INV_SZ = 50000
static

The maximum number of entries in an 'inv' protocol message.

Definition at line 102 of file net_processing.cpp.

◆ MAX_LOCATOR_SZ

const unsigned int MAX_LOCATOR_SZ = 101
static

The maximum number of entries in a locator.

Definition at line 100 of file net_processing.cpp.

◆ MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT

constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4
staticconstexpr

Protect at least this many outbound peers from disconnection due to slow/behind headers chain.

Definition at line 68 of file net_processing.cpp.

◆ MAX_PCT_ADDR_TO_SEND

constexpr size_t MAX_PCT_ADDR_TO_SEND = 23
staticconstexpr

the maximum percentage of addresses from our addrman to return in response to a getaddr message.

Definition at line 279 of file net_processing.cpp.

◆ MAX_UNCONNECTING_HEADERS

const int MAX_UNCONNECTING_HEADERS = 10
static

Maximum number of unconnecting headers announcements before DoS score.

Definition at line 219 of file net_processing.cpp.

◆ MINIMUM_CONNECT_TIME

constexpr int64_t MINIMUM_CONNECT_TIME = 30
staticconstexpr

Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds.

Definition at line 86 of file net_processing.cpp.

◆ NODE_NETWORK_LIMITED_MIN_BLOCKS

const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288
static

Minimum blocks required to signal NODE_NETWORK_LIMITED.

Definition at line 221 of file net_processing.cpp.

◆ ORPHAN_TX_EXPIRE_INTERVAL

constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60
staticconstexpr

Minimum time between orphan transactions expire time checks in seconds.

Definition at line 50 of file net_processing.cpp.

◆ ORPHAN_TX_EXPIRE_TIME

constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60
staticconstexpr

Expiration time for orphan transactions in seconds.

Definition at line 48 of file net_processing.cpp.

◆ PING_INTERVAL

constexpr std::chrono::minutes PING_INTERVAL {2}
staticconstexpr

Time between pings automatically sent out for latency probing and keepalive.

Definition at line 98 of file net_processing.cpp.

◆ PROOF_REQUEST_PARAMS

constexpr DataRequestParameters PROOF_REQUEST_PARAMS
staticconstexpr
Initial value:
{
100,
5000,
std::chrono::seconds(2),
std::chrono::seconds(2),
std::chrono::seconds(60),
}

Definition at line 156 of file net_processing.cpp.

◆ RANDOMIZER_ID_ADDRESS_RELAY

constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL
staticconstexpr

SHA256("main address relay")[0:8].

Definition at line 88 of file net_processing.cpp.

◆ RELAY_TX_CACHE_TIME

constexpr auto RELAY_TX_CACHE_TIME = 15min
staticconstexpr

How long to cache transactions in mapRelay for normal relay.

Definition at line 52 of file net_processing.cpp.

◆ STALE_CHECK_INTERVAL

constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60
staticconstexpr

How frequently to check for stale tips, in seconds.

Definition at line 77 of file net_processing.cpp.

◆ STALE_RELAY_AGE_LIMIT

constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60
staticconstexpr

Age after which a stale block will no longer be served if requested as protection against fingerprinting.

Set to one month, denominated in seconds.

Definition at line 91 of file net_processing.cpp.

◆ TX_REQUEST_PARAMS

constexpr DataRequestParameters TX_REQUEST_PARAMS
staticconstexpr
Initial value:
{
100,
5000,
std::chrono::seconds(2),
std::chrono::seconds(2),
std::chrono::seconds(60),
}

Definition at line 147 of file net_processing.cpp.

◆ UNCONDITIONAL_RELAY_DELAY

constexpr auto UNCONDITIONAL_RELAY_DELAY = 2min
staticconstexpr

How long a transaction has to be in the mempool before it can unconditionally be relayed (even when not in mapRelay).

Definition at line 57 of file net_processing.cpp.

PF_RELAY
@ PF_RELAY
Definition: net_permissions.h:24
PF_BYPASS_PROOF_REQUEST_LIMITS
@ PF_BYPASS_PROOF_REQUEST_LIMITS
Definition: net_permissions.h:39
INBOUND_INVENTORY_BROADCAST_INTERVAL
static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL
Average delay between trickled inventory transmissions for inbound peers.
Definition: net_processing.cpp:234
cs_main
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:103
INVENTORY_BROADCAST_PER_SECOND
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND
Maximum rate of inventory items to send per second.
Definition: net_processing.cpp:239
count_seconds
constexpr int64_t count_seconds(std::chrono::seconds t)
Helper to count the seconds of a duration.
Definition: time.h:27
AssertLockHeld
AssertLockHeld(g_cs_orphans)