36
36
# error "Bitcoin cannot be compiled without assertions."
37
37
#endif
38
38
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
+
39
70
std::atomic<int64_t > nTimeBestReceived (0 ); // Used only to inform the wallet of when we last received a block
40
71
41
72
struct IteratorComparator
@@ -57,20 +88,12 @@ static CCriticalSection g_cs_orphans;
57
88
std::map<uint256, COrphanTx> mapOrphanTransactions GUARDED_BY (g_cs_orphans);
58
89
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY (g_cs_orphans);
59
90
void EraseOrphansFor (NodeId peer);
91
+ /* * Increase a node's misbehavior score. */
92
+ void Misbehaving (NodeId nodeid, int howmuch, const std::string& message=" " );
60
93
61
94
static size_t vExtraTxnForCompactIt GUARDED_BY (g_cs_orphans) = 0;
62
95
static std::vector<std::pair<uint256, CTransactionRef>> vExtraTxnForCompact GUARDED_BY (g_cs_orphans);
63
96
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
-
74
97
// Internal stuff
75
98
namespace {
76
99
/* * Enable BIP61 (sending reject messages) */
0 commit comments