Bitcoin Core  0.20.99
P2P Digital Currency
Classes | Functions | Variables
net_processing.cpp File Reference
#include <net_processing.h>
#include <addrman.h>
#include <banman.h>
#include <blockencodings.h>
#include <blockfilter.h>
#include <chainparams.h>
#include <consensus/validation.h>
#include <hash.h>
#include <index/blockfilterindex.h>
#include <validation.h>
#include <merkleblock.h>
#include <netmessagemaker.h>
#include <netbase.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 <tinyformat.h>
#include <txmempool.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <memory>
#include <typeinfo>
Include dependency graph for net_processing.cpp:

Go to the source code of this file.

Classes

struct  COrphanTx
 
class  CNetProcessingCleanup
 

Functions

std::map< uint256, COrphanTx > mapOrphanTransactions GUARDED_BY (g_cs_orphans)
 
void EraseOrphansFor (NodeId peer)
 
void Misbehaving (NodeId nodeid, int howmuch, const std::string &message="") EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Increase a node's misbehavior score. More...
 
void UpdateLastBlockAnnounceTime (NodeId node, int64_t time_in_seconds)
 
static bool IsOutboundDisconnectionCandidate (const CNode *node)
 
bool GetNodeStateStats (NodeId nodeid, CNodeStateStats &stats)
 Get statistics from node state. More...
 
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 (uint256 hash) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans)
 
unsigned int LimitOrphanTxSize (unsigned int nMaxOrphans)
 
static bool MaybePunishNodeForBlock (NodeId nodeid, const BlockValidationState &state, bool via_compact_block, const std::string &message="")
 Potentially ban a node based on the contents of a BlockValidationState object. More...
 
static bool MaybePunishNodeForTx (NodeId nodeid, const TxValidationState &state, const std::string &message="")
 Potentially ban a node based on the contents of a TxValidationState object. More...
 
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 AlreadyHave (const CInv &inv, const CTxMemPool &mempool) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
void RelayTransaction (const uint256 &txid, const CConnman &connman)
 Relay transaction to every node. More...
 
static void RelayAddress (const CAddress &addr, bool fReachable, const CConnman &connman)
 
static void ProcessGetBlockData (CNode *pfrom, const CChainParams &chainparams, const CInv &inv, CConnman *connman)
 
static CTransactionRef FindTxForGetData (CNode *peer, const uint256 &txid, const std::chrono::seconds mempool_req, const std::chrono::seconds longlived_mempool_time) 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 void ProcessGetData (CNode *pfrom, const CChainParams &chainparams, CConnman *connman, CTxMemPool &mempool, const std::atomic< bool > &interruptMsgProc) LOCKS_EXCLUDED(cs_main)
 
static uint32_t GetFetchFlags (CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 
static void SendBlockTransactions (const CBlock &block, const BlockTransactionsRequest &req, CNode *pfrom, CConnman *connman)
 
static bool ProcessHeadersMessage (CNode *pfrom, CConnman *connman, ChainstateManager &chainman, CTxMemPool &mempool, const std::vector< CBlockHeader > &headers, const CChainParams &chainparams, bool via_compact_block)
 
static void ProcessOrphanTx (CConnman *connman, CTxMemPool &mempool, std::set< uint256 > &orphan_work_set, std::list< CTransactionRef > &removed_txn) EXCLUSIVE_LOCKS_REQUIRED(cs_main
 
 AssertLockHeld (g_cs_orphans)
 
 while (!done &&!orphan_work_set.empty())
 
static bool PrepareBlockFilterRequest (CNode *pfrom, const CChainParams &chain_params, BlockFilterType filter_type, const uint256 &stop_hash, const CBlockIndex *&stop_index, BlockFilterIndex *&filter_index)
 Validation logic for compact filters request handling. More...
 
static void ProcessGetCFCheckPt (CNode *pfrom, CDataStream &vRecv, const CChainParams &chain_params, CConnman *connman)
 Handle a getcfcheckpt request. More...
 
bool ProcessMessage (CNode *pfrom, const std::string &msg_type, CDataStream &vRecv, int64_t nTimeReceived, const CChainParams &chainparams, ChainstateManager &chainman, CTxMemPool &mempool, CConnman *connman, BanMan *banman, const std::atomic< bool > &interruptMsgProc)
 

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 std::chrono::seconds RELAY_TX_CACHE_TIME {15 * 60}
 How long to cache transactions in mapRelay for normal relay. More...
 
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000
 Headers download timeout expressed in microseconds Timeout = base + per_header * (expected number of headers) More...
 
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000
 
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 const int PING_INTERVAL = 2 * 60
 Time between pings automatically sent out for latency probing and keepalive (in seconds). 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 int32_t MAX_PEER_TX_IN_FLIGHT = 100
 Maximum number of in-flight transactions from a peer. More...
 
static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 2 * MAX_INV_SZ
 Maximum number of announced transactions from a peer. More...
 
static constexpr std::chrono::microseconds INBOUND_PEER_TX_DELAY {std::chrono::seconds{2}}
 How many microseconds to delay requesting transactions from inbound peers. More...
 
static constexpr std::chrono::microseconds GETDATA_TX_INTERVAL {std::chrono::seconds{60}}
 How long to wait (in microseconds) before downloading a transaction from an additional peer. More...
 
static constexpr std::chrono::microseconds MAX_GETDATA_RANDOM_DELAY {std::chrono::seconds{2}}
 Maximum delay (in microseconds) for transaction requests to avoid biasing some peers over others. More...
 
static constexpr std::chrono::microseconds TX_EXPIRY_INTERVAL {GETDATA_TX_INTERVAL * 10}
 How long to wait (in microseconds) before expiring an in-flight getdata request to a peer. More...
 
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 const unsigned int BLOCK_STALLING_TIMEOUT = 2
 Timeout in seconds 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 const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000
 Block download timeout base, expressed in millionths of the block interval (i.e. More...
 
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000
 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 std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL {24}
 Average delay between local address broadcasts. More...
 
static constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL {30}
 Average delay between peer address broadcasts. More...
 
static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5
 Average delay between trickled inventory transmissions in seconds. More...
 
static constexpr unsigned int INVENTORY_BROADCAST_MAX = 7 * INVENTORY_BROADCAST_INTERVAL
 Maximum number of inventory items to send per transmission. More...
 
static constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60
 Average delay between feefilter broadcasts in seconds. More...
 
static constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60
 Maximum feefilter broadcast delay after significant change. More...
 
RecursiveMutex g_cs_orphans
 
static RecursiveMutex cs_most_recent_block
 
std::set< NodeIdsetMisbehaving
 
bool done = false
 
static CNetProcessingCleanup instance_of_cnetprocessingcleanup
 

Function Documentation

◆ AddOrphanTx()

bool AddOrphanTx ( const CTransactionRef tx,
NodeId  peer 
)

Definition at line 899 of file net_processing.cpp.

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

◆ AddToCompactExtraTransactions()

static void AddToCompactExtraTransactions ( const CTransactionRef tx)
static

Definition at line 888 of file net_processing.cpp.

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

◆ AlreadyHave()

static bool AlreadyHave ( const CInv inv,
const CTxMemPool mempool 
)
static

Definition at line 1376 of file net_processing.cpp.

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

◆ AssertLockHeld()

AssertLockHeld ( g_cs_orphans  )

◆ BlockRequestAllowed()

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

Definition at line 1147 of file net_processing.cpp.

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

◆ EraseOrphansFor()

void EraseOrphansFor ( NodeId  peer)

Definition at line 963 of file net_processing.cpp.

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

◆ EraseOrphanTx()

static int EraseOrphanTx ( uint256  hash)
static

Definition at line 933 of file net_processing.cpp.

Here is the caller graph for this function:

◆ FindTxForGetData()

static CTransactionRef FindTxForGetData ( CNode peer,
const uint256 txid,
const std::chrono::seconds  mempool_req,
const std::chrono::seconds  longlived_mempool_time 
)
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 1616 of file net_processing.cpp.

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

◆ GetFetchFlags()

static uint32_t GetFetchFlags ( CNode pfrom)
static

Definition at line 1718 of file net_processing.cpp.

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

◆ GetNodeStateStats()

bool GetNodeStateStats ( NodeId  nodeid,
CNodeStateStats stats 
)

Get statistics from node state.

Definition at line 868 of file net_processing.cpp.

Here is the caller graph for this function:

◆ GUARDED_BY() [1/2]

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

◆ GUARDED_BY() [2/2]

static bool fWitnessesPresentInMostRecentCompactBlock GUARDED_BY ( cs_most_recent_block  )
static

◆ IsOutboundDisconnectionCandidate()

static bool IsOutboundDisconnectionCandidate ( const CNode node)
static

Definition at line 798 of file net_processing.cpp.

Here is the caller graph for this function:

◆ LimitOrphanTxSize()

unsigned int LimitOrphanTxSize ( unsigned int  nMaxOrphans)

Definition at line 980 of file net_processing.cpp.

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

◆ MaybePunishNodeForBlock()

static bool MaybePunishNodeForBlock ( NodeId  nodeid,
const BlockValidationState state,
bool  via_compact_block,
const std::string &  message = "" 
)
static

Potentially ban a node based on the contents of a BlockValidationState object.

Parameters
[in]via_compact_blockthis bool is passed in because net_processing should punish peers differently depending on whether the data was provided in a compact block message or not. If the compact block had a valid header, but contained invalid txs, the peer should not be punished. See BIP 152.
Returns
Returns true if the peer was punished (probably disconnected)

Definition at line 1049 of file net_processing.cpp.

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

◆ MaybePunishNodeForTx()

static bool MaybePunishNodeForTx ( NodeId  nodeid,
const TxValidationState state,
const std::string &  message = "" 
)
static

Potentially ban a node based on the contents of a TxValidationState object.

Returns
Returns true if the peer was punished (probably disconnected)

Definition at line 1109 of file net_processing.cpp.

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

◆ Misbehaving()

void Misbehaving ( NodeId  nodeid,
int  howmuch,
const std::string &  message = "" 
)

Increase a node's misbehavior score.

Mark a misbehaving peer to be banned depending upon the value of -banscore.

Definition at line 1019 of file net_processing.cpp.

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

◆ PrepareBlockFilterRequest()

static bool PrepareBlockFilterRequest ( CNode pfrom,
const CChainParams chain_params,
BlockFilterType  filter_type,
const uint256 stop_hash,
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]pfromThe 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]stop_hashThe stop_hash for the request
[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 1997 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 ( CNode pfrom,
const CChainParams chainparams,
const CInv inv,
CConnman connman 
)
static

Definition at line 1460 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 pfrom,
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]pfromThe 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 2045 of file net_processing.cpp.

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

◆ ProcessGetData()

static void ProcessGetData ( CNode pfrom,
const CChainParams chainparams,
CConnman connman,
CTxMemPool mempool,
const std::atomic< bool > &  interruptMsgProc 
)
static

Definition at line 1646 of file net_processing.cpp.

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

◆ ProcessHeadersMessage()

static bool ProcessHeadersMessage ( CNode pfrom,
CConnman connman,
ChainstateManager chainman,
CTxMemPool mempool,
const std::vector< CBlockHeader > &  headers,
const CChainParams chainparams,
bool  via_compact_block 
)
static

Definition at line 1742 of file net_processing.cpp.

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

◆ ProcessMessage()

bool ProcessMessage ( CNode pfrom,
const std::string &  msg_type,
CDataStream vRecv,
int64_t  nTimeReceived,
const CChainParams chainparams,
ChainstateManager chainman,
CTxMemPool mempool,
CConnman connman,
BanMan banman,
const std::atomic< bool > &  interruptMsgProc 
)

Definition at line 2085 of file net_processing.cpp.

Here is the caller graph for this function:

◆ ProcessOrphanTx()

static void ProcessOrphanTx ( CConnman connman,
CTxMemPool mempool,
std::set< uint256 > &  orphan_work_set,
std::list< CTransactionRef > &  removed_txn 
)
static
Here is the caller graph for this function:

◆ RelayAddress()

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

Definition at line 1424 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 uint256 txid,
const CConnman connman 
)

Relay transaction to every node.

Definition at line 1415 of file net_processing.cpp.

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

◆ SendBlockTransactions()

static void SendBlockTransactions ( const CBlock block,
const BlockTransactionsRequest req,
CNode pfrom,
CConnman connman 
)
inlinestatic

Definition at line 1726 of file net_processing.cpp.

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

◆ UpdateLastBlockAnnounceTime()

void UpdateLastBlockAnnounceTime ( NodeId  node,
int64_t  time_in_seconds 
)

Definition at line 789 of file net_processing.cpp.

◆ while()

while ( !done &&!orphan_work_set.  empty())

Definition at line 1930 of file net_processing.cpp.

Here is the call graph for this function:

Variable Documentation

◆ AVG_ADDRESS_BROADCAST_INTERVAL

constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL {30}
static

Average delay between peer address broadcasts.

Definition at line 121 of file net_processing.cpp.

◆ AVG_FEEFILTER_BROADCAST_INTERVAL

constexpr unsigned int AVG_FEEFILTER_BROADCAST_INTERVAL = 10 * 60
static

Average delay between feefilter broadcasts in seconds.

Definition at line 129 of file net_processing.cpp.

◆ AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL

constexpr std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL {24}
static

Average delay between local address broadcasts.

Definition at line 119 of file net_processing.cpp.

◆ BLOCK_DOWNLOAD_TIMEOUT_BASE

const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000
static

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

10 min)

Definition at line 109 of file net_processing.cpp.

◆ BLOCK_DOWNLOAD_TIMEOUT_PER_PEER

const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000
static

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

5 min)

Definition at line 111 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 107 of file net_processing.cpp.

◆ BLOCK_STALLING_TIMEOUT

const unsigned int BLOCK_STALLING_TIMEOUT = 2
static

Timeout in seconds during which a peer must stall block download progress before being disconnected.

Definition at line 94 of file net_processing.cpp.

◆ CHAIN_SYNC_TIMEOUT

constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60
static

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

Definition at line 54 of file net_processing.cpp.

◆ cs_most_recent_block

RecursiveMutex cs_most_recent_block
static

Definition at line 1249 of file net_processing.cpp.

◆ done

bool done = false

Definition at line 1929 of file net_processing.cpp.

◆ EXTRA_PEER_CHECK_INTERVAL

constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45
static

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

Definition at line 58 of file net_processing.cpp.

◆ g_cs_orphans

static void g_cs_orphans
Initial value:
{
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Definition: validation.cpp:124
AssertLockHeld(g_cs_orphans)

Definition at line 140 of file net_processing.cpp.

◆ GETDATA_TX_INTERVAL

constexpr std::chrono::microseconds GETDATA_TX_INTERVAL {std::chrono::seconds{60}}
static

How long to wait (in microseconds) before downloading a transaction from an additional peer.

Definition at line 82 of file net_processing.cpp.

◆ HEADERS_DOWNLOAD_TIMEOUT_BASE

constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000
static

Headers download timeout expressed in microseconds Timeout = base + per_header * (expected number of headers)

Definition at line 47 of file net_processing.cpp.

◆ HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER

constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000
static

Definition at line 48 of file net_processing.cpp.

◆ HISTORICAL_BLOCK_AGE

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

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 68 of file net_processing.cpp.

◆ INBOUND_PEER_TX_DELAY

constexpr std::chrono::microseconds INBOUND_PEER_TX_DELAY {std::chrono::seconds{2}}
static

How many microseconds to delay requesting transactions from inbound peers.

Definition at line 80 of file net_processing.cpp.

◆ instance_of_cnetprocessingcleanup

CNetProcessingCleanup instance_of_cnetprocessingcleanup
static

Definition at line 4297 of file net_processing.cpp.

◆ INVENTORY_BROADCAST_INTERVAL

const unsigned int INVENTORY_BROADCAST_INTERVAL = 5
static

Average delay between trickled inventory transmissions in seconds.

Blocks and whitelisted receivers bypass this, outbound peers get half this delay.

Definition at line 124 of file net_processing.cpp.

◆ INVENTORY_BROADCAST_MAX

constexpr unsigned int INVENTORY_BROADCAST_MAX = 7 * INVENTORY_BROADCAST_INTERVAL
static

Maximum number of inventory items to send per transmission.

Limits the impact of low-fee transaction floods.

Definition at line 127 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 92 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 113 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 102 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 100 of file net_processing.cpp.

◆ MAX_FEEFILTER_CHANGE_DELAY

constexpr unsigned int MAX_FEEFILTER_CHANGE_DELAY = 5 * 60
static

Maximum feefilter broadcast delay after significant change.

Definition at line 131 of file net_processing.cpp.

◆ MAX_GETDATA_RANDOM_DELAY

constexpr std::chrono::microseconds MAX_GETDATA_RANDOM_DELAY {std::chrono::seconds{2}}
static

Maximum delay (in microseconds) for transaction requests to avoid biasing some peers over others.

Definition at line 84 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 90 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 97 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 74 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 72 of file net_processing.cpp.

◆ MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT

constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4
static

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

Definition at line 52 of file net_processing.cpp.

◆ MAX_PEER_TX_ANNOUNCEMENTS

constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 2 * MAX_INV_SZ
static

Maximum number of announced transactions from a peer.

Definition at line 78 of file net_processing.cpp.

◆ MAX_PEER_TX_IN_FLIGHT

constexpr int32_t MAX_PEER_TX_IN_FLIGHT = 100
static

Maximum number of in-flight transactions from a peer.

Definition at line 76 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 115 of file net_processing.cpp.

◆ MINIMUM_CONNECT_TIME

constexpr int64_t MINIMUM_CONNECT_TIME = 30
static

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

Definition at line 60 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 117 of file net_processing.cpp.

◆ ORPHAN_TX_EXPIRE_INTERVAL

constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60
static

Minimum time between orphan transactions expire time checks in seconds.

Definition at line 42 of file net_processing.cpp.

◆ ORPHAN_TX_EXPIRE_TIME

constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60
static

Expiration time for orphan transactions in seconds.

Definition at line 40 of file net_processing.cpp.

◆ PING_INTERVAL

const int PING_INTERVAL = 2 * 60
static

Time between pings automatically sent out for latency probing and keepalive (in seconds).

Definition at line 70 of file net_processing.cpp.

◆ RANDOMIZER_ID_ADDRESS_RELAY

constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL
static

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

Definition at line 62 of file net_processing.cpp.

◆ RELAY_TX_CACHE_TIME

constexpr std::chrono::seconds RELAY_TX_CACHE_TIME {15 * 60}
static

How long to cache transactions in mapRelay for normal relay.

Definition at line 44 of file net_processing.cpp.

◆ setMisbehaving

std::set<NodeId> setMisbehaving

Definition at line 1928 of file net_processing.cpp.

◆ STALE_CHECK_INTERVAL

constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60
static

How frequently to check for stale tips, in seconds.

Definition at line 56 of file net_processing.cpp.

◆ STALE_RELAY_AGE_LIMIT

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

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 65 of file net_processing.cpp.

◆ TX_EXPIRY_INTERVAL

constexpr std::chrono::microseconds TX_EXPIRY_INTERVAL {GETDATA_TX_INTERVAL * 10}
static

How long to wait (in microseconds) before expiring an in-flight getdata request to a peer.

Definition at line 86 of file net_processing.cpp.