Skip to content

Commit b8580ca

Browse files
committed
[net processing] Move net processing consts to net_processing.cpp
1 parent 47b94a3 commit b8580ca

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

src/net.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,10 @@ static const bool DEFAULT_WHITELISTRELAY = true;
4545
/** Default for -whitelistforcerelay. */
4646
static const bool DEFAULT_WHITELISTFORCERELAY = false;
4747

48-
/** Time between pings automatically sent out for latency probing and keepalive (in seconds). */
49-
static const int PING_INTERVAL = 2 * 60;
5048
/** Time after which to disconnect, after waiting for a ping response (or inactivity). */
5149
static const int TIMEOUT_INTERVAL = 20 * 60;
5250
/** Run the feeler connection loop once every 2 minutes or 120 seconds. **/
5351
static const int FEELER_INTERVAL = 120;
54-
/** The maximum number of entries in an 'inv' protocol message */
55-
static const unsigned int MAX_INV_SZ = 50000;
56-
/** The maximum number of entries in a locator */
57-
static const unsigned int MAX_LOCATOR_SZ = 101;
5852
/** The maximum number of new addresses to accumulate before announcing. */
5953
static const unsigned int MAX_ADDR_TO_SEND = 1000;
6054
/** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */

src/net_processing.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60;
6464
/// Age after which a block is considered historical for purposes of rate
6565
/// limiting block relay. Set to one week, denominated in seconds.
6666
static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60;
67+
/** Time between pings automatically sent out for latency probing and keepalive (in seconds). */
68+
static const int PING_INTERVAL = 2 * 60;
69+
/** The maximum number of entries in a locator */
70+
static const unsigned int MAX_LOCATOR_SZ = 101;
71+
/** The maximum number of entries in an 'inv' protocol message */
72+
static const unsigned int MAX_INV_SZ = 50000;
6773
/** Maximum number of in-flight transactions from a peer */
6874
static constexpr int32_t MAX_PEER_TX_IN_FLIGHT = 100;
6975
/** Maximum number of announced transactions from a peer */
@@ -80,6 +86,33 @@ static_assert(INBOUND_PEER_TX_DELAY >= MAX_GETDATA_RANDOM_DELAY,
8086
"To preserve security, MAX_GETDATA_RANDOM_DELAY should not exceed INBOUND_PEER_DELAY");
8187
/** Limit to avoid sending big packets. Not used in processing incoming GETDATA for compatibility */
8288
static const unsigned int MAX_GETDATA_SZ = 1000;
89+
/** Number of blocks that can be requested at any given time from a single peer. */
90+
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
91+
/** Timeout in seconds during which a peer must stall block download progress before being disconnected. */
92+
static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
93+
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
94+
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
95+
static const unsigned int MAX_HEADERS_RESULTS = 2000;
96+
/** Maximum depth of blocks we're willing to serve as compact blocks to peers
97+
* when requested. For older blocks, a regular BLOCK response will be sent. */
98+
static const int MAX_CMPCTBLOCK_DEPTH = 5;
99+
/** Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. */
100+
static const int MAX_BLOCKTXN_DEPTH = 10;
101+
/** Size of the "block download window": how far ahead of our current height do we fetch?
102+
* Larger windows tolerate larger download speed differences between peer, but increase the potential
103+
* degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably
104+
* want to make this a per-peer adaptive value at some point. */
105+
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
106+
/** Block download timeout base, expressed in millionths of the block interval (i.e. 10 min) */
107+
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000;
108+
/** Additional block download timeout per parallel downloading peer (i.e. 5 min) */
109+
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000;
110+
/** Maximum number of headers to announce when relaying blocks with headers message.*/
111+
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
112+
/** Maximum number of unconnecting headers announcements before DoS score */
113+
static const int MAX_UNCONNECTING_HEADERS = 10;
114+
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */
115+
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
83116

84117

85118
struct COrphanTx {

src/validation.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,10 @@ static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
8181
static const int MAX_SCRIPTCHECK_THREADS = 15;
8282
/** -par default (number of script-checking threads, 0 = auto) */
8383
static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
84-
/** Number of blocks that can be requested at any given time from a single peer. */
85-
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
86-
/** Timeout in seconds during which a peer must stall block download progress before being disconnected. */
87-
static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
88-
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
89-
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
90-
static const unsigned int MAX_HEADERS_RESULTS = 2000;
91-
/** Maximum depth of blocks we're willing to serve as compact blocks to peers
92-
* when requested. For older blocks, a regular BLOCK response will be sent. */
93-
static const int MAX_CMPCTBLOCK_DEPTH = 5;
94-
/** Maximum depth of blocks we're willing to respond to GETBLOCKTXN requests for. */
95-
static const int MAX_BLOCKTXN_DEPTH = 10;
96-
/** Size of the "block download window": how far ahead of our current height do we fetch?
97-
* Larger windows tolerate larger download speed differences between peer, but increase the potential
98-
* degree of disordering of blocks on disk (which make reindexing and pruning harder). We'll probably
99-
* want to make this a per-peer adaptive value at some point. */
100-
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
10184
/** Time to wait (in seconds) between writing blocks/block index to disk. */
10285
static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
10386
/** Time to wait (in seconds) between flushing chainstate to disk. */
10487
static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
105-
/** Block download timeout base, expressed in millionths of the block interval (i.e. 10 min) */
106-
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_BASE = 1000000;
107-
/** Additional block download timeout per parallel downloading peer (i.e. 5 min) */
108-
static const int64_t BLOCK_DOWNLOAD_TIMEOUT_PER_PEER = 500000;
10988

11089
static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
11190
/** Maximum age of our tip in seconds for us to be considered current for fee estimation */
@@ -120,12 +99,6 @@ static const bool DEFAULT_PERSIST_MEMPOOL = true;
12099
/** Default for using fee filter */
121100
static const bool DEFAULT_FEEFILTER = true;
122101

123-
/** Maximum number of headers to announce when relaying blocks with headers message.*/
124-
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
125-
126-
/** Maximum number of unconnecting headers announcements before DoS score */
127-
static const int MAX_UNCONNECTING_HEADERS = 10;
128-
129102
/** Default for -stopatheight */
130103
static const int DEFAULT_STOPATHEIGHT = 0;
131104

@@ -177,8 +150,6 @@ extern bool fPruneMode;
177150
extern uint64_t nPruneTarget;
178151
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ::ChainActive().Tip() will not be pruned. */
179152
static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
180-
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */
181-
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
182153

183154
static const signed int DEFAULT_CHECKBLOCKS = 6;
184155
static const unsigned int DEFAULT_CHECKLEVEL = 3;

0 commit comments

Comments
 (0)