37
37
#endif
38
38
39
39
/* * Expiration time for orphan transactions in seconds */
40
- static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60 ;
40
+ static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60 ;
41
41
/* * Minimum time between orphan transactions expire time checks in seconds */
42
- static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60 ;
42
+ static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60 ;
43
43
/* * Headers download timeout expressed in microseconds
44
44
* Timeout = base + per_header * (expected number of headers) */
45
45
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000 ; // 15 minutes
@@ -56,27 +56,14 @@ static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60; // 10 minutes
56
56
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45 ;
57
57
/* * Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds */
58
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
-
59
+ /* * SHA256("main address relay")[0:8] */
60
+ static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL ;
62
61
// / Age after which a stale block will no longer be served if requested as
63
62
// / protection against fingerprinting. Set to one month, denominated in seconds.
64
- static const int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60 ;
65
-
63
+ static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60 ;
66
64
// / Age after which a block is considered historical for purposes of rate
67
65
// / limiting block relay. Set to one week, denominated in seconds.
68
- static const int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60 ;
69
-
70
- std::atomic<int64_t > nTimeBestReceived (0 ); // Used only to inform the wallet of when we last received a block
71
-
72
- struct IteratorComparator
73
- {
74
- template <typename I>
75
- bool operator ()(const I& a, const I& b) const
76
- {
77
- return &(*a) < &(*b);
78
- }
79
- };
66
+ static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60 ;
80
67
81
68
struct COrphanTx {
82
69
// When modifying, adapt the copy of this definition in tests/DoS_tests.
@@ -86,14 +73,12 @@ struct COrphanTx {
86
73
};
87
74
static CCriticalSection g_cs_orphans;
88
75
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY (g_cs_orphans);
89
- std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans);
76
+
90
77
void EraseOrphansFor (NodeId peer);
78
+
91
79
/* * Increase a node's misbehavior score. */
92
80
void Misbehaving (NodeId nodeid, int howmuch, const std::string& message=" " );
93
81
94
- static size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
95
- static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY (g_cs_orphans);
96
-
97
82
// Internal stuff
98
83
namespace {
99
84
/* * Enable BIP61 (sending reject messages) */
@@ -163,10 +148,24 @@ namespace {
163
148
MapRelay mapRelay;
164
149
/* * Expiration-time ordered list of (expire time, relay map entry) pairs, protected by cs_main). */
165
150
std::deque<std::pair<int64_t , MapRelay::iterator>> vRelayExpiration;
151
+
152
+ std::atomic<int64_t > nTimeBestReceived (0 ); // Used only to inform the wallet of when we last received a block
153
+
154
+ struct IteratorComparator
155
+ {
156
+ template <typename I>
157
+ bool operator ()(const I& a, const I& b) const
158
+ {
159
+ return &(*a) < &(*b);
160
+ }
161
+ };
162
+ std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans);
163
+
164
+ static size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
165
+ static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY (g_cs_orphans);
166
166
} // namespace
167
167
168
168
namespace {
169
-
170
169
struct CBlockReject {
171
170
unsigned char chRejectCode;
172
171
std::string strRejectReason;
@@ -293,10 +292,10 @@ struct CNodeState {
293
292
};
294
293
295
294
/* * Map maintaining per-node state. Requires cs_main. */
296
- std::map<NodeId, CNodeState> mapNodeState;
295
+ static std::map<NodeId, CNodeState> mapNodeState;
297
296
298
297
// Requires cs_main.
299
- CNodeState *State (NodeId pnode) {
298
+ static CNodeState *State (NodeId pnode) {
300
299
std::map<NodeId, CNodeState>::iterator it = mapNodeState.find (pnode);
301
300
if (it == mapNodeState.end ())
302
301
return nullptr ;
@@ -3229,6 +3228,7 @@ void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params
3229
3228
}
3230
3229
}
3231
3230
3231
+ namespace {
3232
3232
class CompareInvMempoolOrder
3233
3233
{
3234
3234
CTxMemPool *mp;
@@ -3245,6 +3245,7 @@ class CompareInvMempoolOrder
3245
3245
return mp->CompareDepthAndScore (*b, *a);
3246
3246
}
3247
3247
};
3248
+ }
3248
3249
3249
3250
bool PeerLogicValidation::SendMessages (CNode* pto, std::atomic<bool >& interruptMsgProc)
3250
3251
{
0 commit comments