Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
/** SHA256("main address relay")[0:8] */ | /** SHA256("main address relay")[0:8] */ | ||||
static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; | static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; | ||||
/// Age after which a stale block will no longer be served if requested as | /// Age after which a stale block will no longer be served if requested as | ||||
/// protection against fingerprinting. Set to one month, denominated in seconds. | /// protection against fingerprinting. Set to one month, denominated in seconds. | ||||
static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60; | static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60; | ||||
/// Age after which a block is considered historical for purposes of rate | /// Age after which a block is considered historical for purposes of rate | ||||
/// limiting block relay. Set to one week, denominated in seconds. | /// limiting block relay. Set to one week, denominated in seconds. | ||||
static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60; | static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60; | ||||
/** | |||||
* Time between pings automatically sent out for latency probing and keepalive | |||||
* (in seconds). | |||||
*/ | |||||
static const int PING_INTERVAL = 2 * 60; | |||||
/** The maximum number of entries in a locator */ | |||||
static const unsigned int MAX_LOCATOR_SZ = 101; | |||||
/** The maximum number of entries in an 'inv' protocol message */ | |||||
static const unsigned int MAX_INV_SZ = 50000; | |||||
static_assert(MAX_PROTOCOL_MESSAGE_LENGTH > MAX_INV_SZ * sizeof(CInv), | |||||
"Max protocol message length must be greater than largest " | |||||
"possible INV message"); | |||||
/** Maximum number of in-flight transactions from a peer */ | /** Maximum number of in-flight transactions from a peer */ | ||||
static constexpr int32_t MAX_PEER_TX_IN_FLIGHT = 100; | static constexpr int32_t MAX_PEER_TX_IN_FLIGHT = 100; | ||||
/** Maximum number of announced transactions from a peer */ | /** Maximum number of announced transactions from a peer */ | ||||
static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 2 * MAX_INV_SZ; | static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 2 * MAX_INV_SZ; | ||||
/** How many microseconds to delay requesting transactions from inbound peers */ | /** How many microseconds to delay requesting transactions from inbound peers */ | ||||
static constexpr std::chrono::microseconds INBOUND_PEER_TX_DELAY{ | static constexpr std::chrono::microseconds INBOUND_PEER_TX_DELAY{ | ||||
std::chrono::seconds{2}}; | std::chrono::seconds{2}}; | ||||
/** | /** | ||||
Show All 17 Lines | |||||
static_assert(INBOUND_PEER_TX_DELAY >= MAX_GETDATA_RANDOM_DELAY, | static_assert(INBOUND_PEER_TX_DELAY >= MAX_GETDATA_RANDOM_DELAY, | ||||
"To preserve security, MAX_GETDATA_RANDOM_DELAY should not " | "To preserve security, MAX_GETDATA_RANDOM_DELAY should not " | ||||
"exceed INBOUND_PEER_DELAY"); | "exceed INBOUND_PEER_DELAY"); | ||||
/** | /** | ||||
* Limit to avoid sending big packets. Not used in processing incoming GETDATA | * Limit to avoid sending big packets. Not used in processing incoming GETDATA | ||||
* for compatibility. | * for compatibility. | ||||
*/ | */ | ||||
static const unsigned int MAX_GETDATA_SZ = 1000; | static const unsigned int MAX_GETDATA_SZ = 1000; | ||||
/** | |||||
* Number of blocks that can be requested at any given time from a single peer. | |||||
*/ | |||||
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16; | |||||
/** | |||||
* Timeout in seconds during which a peer must stall block download progress | |||||
* before being disconnected. | |||||
*/ | |||||
static const unsigned int BLOCK_STALLING_TIMEOUT = 2; | |||||
/** | |||||
* 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. | |||||
*/ | |||||
static const unsigned int MAX_HEADERS_RESULTS = 2000; | |||||
/** | |||||
* 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. | |||||
*/ | |||||
static const int MAX_CMPCTBLOCK_DEPTH = 5; | |||||
/** | |||||
* Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests | |||||
* for. | |||||
*/ | |||||
static const int MAX_BLOCKTXN_DEPTH = 10; | |||||
/** | |||||
* 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. | |||||
*/ | |||||
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024; | |||||
/** | |||||
* Block download timeout base, expressed in millionths of the block interval | |||||
* (i.e. 10 min) | |||||
*/ | |||||
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000; | |||||
/** | |||||
* Additional block download timeout per parallel downloading peer (i.e. 5 min) | |||||
*/ | |||||
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000; | |||||
/** | |||||
* Maximum number of headers to announce when relaying blocks with headers | |||||
* message. | |||||
*/ | |||||
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8; | |||||
/** Maximum number of unconnecting headers announcements before DoS score */ | |||||
static const int MAX_UNCONNECTING_HEADERS = 10; | |||||
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */ | |||||
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288; | |||||
/// How many non standard orphan do we consider from a node before ignoring it. | /// How many non standard orphan do we consider from a node before ignoring it. | ||||
static constexpr uint32_t MAX_NON_STANDARD_ORPHAN_PER_NODE = 5; | static constexpr uint32_t MAX_NON_STANDARD_ORPHAN_PER_NODE = 5; | ||||
struct COrphanTx { | struct COrphanTx { | ||||
// When modifying, adapt the copy of this definition in tests/DoS_tests. | // When modifying, adapt the copy of this definition in tests/DoS_tests. | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
NodeId fromPeer; | NodeId fromPeer; | ||||
▲ Show 20 Lines • Show All 5,316 Lines • Show Last 20 Lines |