Skip to content

Commit 1d4df02

Browse files
committed
[move-only] Move things only referenced in net_processing out of header file
1 parent 02bbc05 commit 1d4df02

File tree

3 files changed

+35
-33
lines changed

3 files changed

+35
-33
lines changed

src/net_processing.cpp

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,37 @@
3636
# error "Bitcoin cannot be compiled without assertions."
3737
#endif
3838

39+
/** Expiration time for orphan transactions in seconds */
40+
static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
41+
/** Minimum time between orphan transactions expire time checks in seconds */
42+
static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
43+
/** Headers download timeout expressed in microseconds
44+
* Timeout = base + per_header * (expected number of headers) */
45+
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000; // 15 minutes
46+
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000; // 1ms/header
47+
/** Protect at least this many outbound peers from disconnection due to slow/
48+
* behind headers chain.
49+
*/
50+
static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4;
51+
/** Timeout for (unprotected) outbound peers to sync to our chainwork, in seconds */
52+
static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60; // 20 minutes
53+
/** How frequently to check for stale tips, in seconds */
54+
static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60; // 10 minutes
55+
/** How frequently to check for extra outbound peers and disconnect, in seconds */
56+
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
57+
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds */
58+
static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
59+
60+
static const uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; // SHA256("main address relay")[0:8]
61+
62+
/// Age after which a stale block will no longer be served if requested as
63+
/// protection against fingerprinting. Set to one month, denominated in seconds.
64+
static const int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60;
65+
66+
/// Age after which a block is considered historical for purposes of rate
67+
/// limiting block relay. Set to one week, denominated in seconds.
68+
static const int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60;
69+
3970
std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of when we last received a block
4071

4172
struct IteratorComparator
@@ -57,20 +88,12 @@ static CCriticalSection g_cs_orphans;
5788
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY(g_cs_orphans);
5889
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans);
5990
void EraseOrphansFor(NodeId peer);
91+
/** Increase a node's misbehavior score. */
92+
void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
6093

6194
static size_t vExtraTxnForCompactIt GUARDED_BY(g_cs_orphans) = 0;
6295
static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY(g_cs_orphans);
6396

64-
static const uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL; // SHA256("main address relay")[0:8]
65-
66-
/// Age after which a stale block will no longer be served if requested as
67-
/// protection against fingerprinting. Set to one month, denominated in seconds.
68-
static const int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60;
69-
70-
/// Age after which a block is considered historical for purposes of rate
71-
/// limiting block relay. Set to one week, denominated in seconds.
72-
static const int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60;
73-
7497
// Internal stuff
7598
namespace {
7699
/** Enable BIP61 (sending reject messages) */

src/net_processing.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,8 @@
1212

1313
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
1414
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
15-
/** Expiration time for orphan transactions in seconds */
16-
static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
17-
/** Minimum time between orphan transactions expire time checks in seconds */
18-
static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
1915
/** Default number of orphan+recently-replaced txn to keep around for block reconstruction */
2016
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
21-
/** Headers download timeout expressed in microseconds
22-
* Timeout = base + per_header * (expected number of headers) */
23-
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000; // 15 minutes
24-
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000; // 1ms/header
25-
/** Protect at least this many outbound peers from disconnection due to slow/
26-
* behind headers chain.
27-
*/
28-
static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4;
29-
/** Timeout for (unprotected) outbound peers to sync to our chainwork, in seconds */
30-
static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60; // 20 minutes
31-
/** How frequently to check for stale tips, in seconds */
32-
static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60; // 10 minutes
33-
/** How frequently to check for extra outbound peers and disconnect, in seconds */
34-
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
35-
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds */
36-
static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
37-
3817
/** Default for BIP61 (sending reject messages) */
3918
static constexpr bool DEFAULT_ENABLE_BIP61 = true;
4019

@@ -97,7 +76,5 @@ struct CNodeStateStats {
9776

9877
/** Get statistics from node state */
9978
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
100-
/** Increase a node's misbehavior score. */
101-
void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
10279

10380
#endif // BITCOIN_NET_PROCESSING_H

src/test/denialofservice_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
extern bool AddOrphanTx(const CTransactionRef& tx, NodeId peer);
2525
extern void EraseOrphansFor(NodeId peer);
2626
extern unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans);
27+
extern void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
28+
2729
struct COrphanTx {
2830
CTransactionRef tx;
2931
NodeId fromPeer;

0 commit comments

Comments
 (0)