@@ -64,7 +64,7 @@ static constexpr auto STALE_CHECK_INTERVAL{10min};
64
64
/* * How frequently to check for extra outbound peers and disconnect */
65
65
static constexpr auto EXTRA_PEER_CHECK_INTERVAL{45s};
66
66
/* * Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict */
67
- static constexpr std::chrono::seconds MINIMUM_CONNECT_TIME{30 };
67
+ static constexpr auto MINIMUM_CONNECT_TIME{30s };
68
68
/* * SHA256("main address relay")[0:8] */
69
69
static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL ;
70
70
// / Age after which a stale block will no longer be served if requested as
@@ -74,7 +74,7 @@ static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60;
74
74
// / limiting block relay. Set to one week, denominated in seconds.
75
75
static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60 ;
76
76
/* * Time between pings automatically sent out for latency probing and keepalive */
77
- static constexpr std::chrono::minutes PING_INTERVAL{2 };
77
+ static constexpr auto PING_INTERVAL{2min };
78
78
/* * The maximum number of entries in a locator */
79
79
static const unsigned int MAX_LOCATOR_SZ = 101 ;
80
80
/* * The maximum number of entries in an 'inv' protocol message */
@@ -88,19 +88,19 @@ static constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100;
88
88
* the actual transaction (from any peer) in response to requests for them. */
89
89
static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000 ;
90
90
/* * How long to delay requesting transactions via txids, if we have wtxid-relaying peers */
91
- static constexpr auto TXID_RELAY_DELAY = std::chrono::seconds{ 2 };
91
+ static constexpr auto TXID_RELAY_DELAY{2s };
92
92
/* * How long to delay requesting transactions from non-preferred peers */
93
- static constexpr auto NONPREF_PEER_TX_DELAY = std::chrono::seconds{ 2 };
93
+ static constexpr auto NONPREF_PEER_TX_DELAY{2s };
94
94
/* * How long to delay requesting transactions from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT). */
95
- static constexpr auto OVERLOADED_PEER_TX_DELAY = std::chrono::seconds{ 2 };
96
- /* * How long to wait (in microseconds) before downloading a transaction from an additional peer */
97
- static constexpr std::chrono::microseconds GETDATA_TX_INTERVAL{std::chrono::seconds{ 60 } };
95
+ static constexpr auto OVERLOADED_PEER_TX_DELAY{2s };
96
+ /* * How long to wait before downloading a transaction from an additional peer */
97
+ static constexpr auto GETDATA_TX_INTERVAL{60s };
98
98
/* * Limit to avoid sending big packets. Not used in processing incoming GETDATA for compatibility */
99
99
static const unsigned int MAX_GETDATA_SZ = 1000 ;
100
100
/* * Number of blocks that can be requested at any given time from a single peer. */
101
101
static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16 ;
102
102
/* * Time during which a peer must stall block download progress before being disconnected. */
103
- static constexpr auto BLOCK_STALLING_TIMEOUT = 2s ;
103
+ static constexpr auto BLOCK_STALLING_TIMEOUT{2s} ;
104
104
/* * Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
105
105
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
106
106
static const unsigned int MAX_HEADERS_RESULTS = 2000 ;
@@ -125,16 +125,16 @@ static const int MAX_UNCONNECTING_HEADERS = 10;
125
125
/* * Minimum blocks required to signal NODE_NETWORK_LIMITED */
126
126
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288 ;
127
127
/* * Average delay between local address broadcasts */
128
- static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24h;
128
+ static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{ 24h} ;
129
129
/* * Average delay between peer address broadcasts */
130
- static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL = 30s;
130
+ static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL{ 30s} ;
131
131
/* * Average delay between trickled inventory transmissions for inbound peers.
132
132
* Blocks and peers with NetPermissionFlags::NoBan permission bypass this. */
133
- static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL = 5s ;
133
+ static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL{5s} ;
134
134
/* * Average delay between trickled inventory transmissions for outbound peers.
135
135
* Use a smaller delay as there is less privacy concern for them.
136
136
* Blocks and peers with NetPermissionFlags::NoBan permission bypass this. */
137
- static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL = 2s ;
137
+ static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL{2s} ;
138
138
/* * Maximum rate of inventory items to send per second.
139
139
* Limits the impact of low-fee transaction floods. */
140
140
static constexpr unsigned int INVENTORY_BROADCAST_PER_SECOND = 7 ;
@@ -148,9 +148,9 @@ static constexpr unsigned int INVENTORY_MAX_RECENT_RELAY = 3500;
148
148
* peers, and random variations in the broadcast mechanism. */
149
149
static_assert (INVENTORY_MAX_RECENT_RELAY >= INVENTORY_BROADCAST_PER_SECOND * UNCONDITIONAL_RELAY_DELAY / std::chrono::seconds{1 }, " INVENTORY_RELAY_MAX too low" );
150
150
/* * Average delay between feefilter broadcasts in seconds. */
151
- static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL = 10min;
151
+ static constexpr auto AVG_FEEFILTER_BROADCAST_INTERVAL{ 10min} ;
152
152
/* * Maximum feefilter broadcast delay after significant change. */
153
- static constexpr auto MAX_FEEFILTER_CHANGE_DELAY = 5min;
153
+ static constexpr auto MAX_FEEFILTER_CHANGE_DELAY{ 5min} ;
154
154
/* * Maximum number of compact filters that may be requested with one getcfilters. See BIP 157. */
155
155
static constexpr uint32_t MAX_GETCFILTERS_SIZE = 1000 ;
156
156
/* * Maximum number of cf hashes that may be requested with one getcfheaders. See BIP 157. */
@@ -727,7 +727,7 @@ struct CNodeState {
727
727
* - its chain tip has at least as much work as ours
728
728
*
729
729
* CHAIN_SYNC_TIMEOUT: if a peer's best known block has less work than our tip,
730
- * set a timeout CHAIN_SYNC_TIMEOUT seconds in the future:
730
+ * set a timeout CHAIN_SYNC_TIMEOUT in the future:
731
731
* - If at timeout their best known block now has more work than our tip
732
732
* when the timeout was set, then either reset the timeout or clear it
733
733
* (after comparing against our current tip's work)
@@ -1137,7 +1137,7 @@ void PeerManagerImpl::AddTxAnnouncement(const CNode& node, const GenTxid& gtxid,
1137
1137
// - TXID_RELAY_DELAY for txid announcements while wtxid peers are available
1138
1138
// - OVERLOADED_PEER_TX_DELAY for announcements from peers which have at least
1139
1139
// MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have NetPermissionFlags::Relay).
1140
- auto delay = std::chrono::microseconds{ 0 };
1140
+ auto delay{0us };
1141
1141
const bool preferred = state->fPreferredDownload ;
1142
1142
if (!preferred) delay += NONPREF_PEER_TX_DELAY;
1143
1143
if (!gtxid.IsWtxid () && m_wtxid_relay_peers > 0 ) delay += TXID_RELAY_DELAY;
@@ -1191,7 +1191,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
1191
1191
1192
1192
// Schedule next run for 10-15 minutes in the future.
1193
1193
// We add randomness on every cycle to avoid the possibility of P2P fingerprinting.
1194
- const std::chrono::milliseconds delta = std::chrono::minutes{ 10 } + GetRandMillis (std::chrono::minutes{ 5 } );
1194
+ const std::chrono::milliseconds delta = 10min + GetRandMillis (5min );
1195
1195
scheduler.scheduleFromNow ([&] { ReattemptInitialBroadcast (scheduler); }, delta);
1196
1196
}
1197
1197
@@ -1296,7 +1296,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c
1296
1296
// since pingtime does not update until the ping is complete, which might take a while.
1297
1297
// So, if a ping is taking an unusually long time in flight,
1298
1298
// the caller can immediately detect that this is happening.
1299
- std::chrono::microseconds ping_wait{0 };
1299
+ auto ping_wait{0us };
1300
1300
if ((0 != peer->m_ping_nonce_sent ) && (0 != peer->m_ping_start .load ().count ())) {
1301
1301
ping_wait = GetTime<std::chrono::microseconds>() - peer->m_ping_start .load ();
1302
1302
}
@@ -1496,7 +1496,7 @@ void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler)
1496
1496
scheduler.scheduleEvery ([this ] { this ->CheckForStaleTipAndEvictPeers (); }, std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL});
1497
1497
1498
1498
// schedule next run for 10-15 minutes in the future
1499
- const std::chrono::milliseconds delta = std::chrono::minutes{ 10 } + GetRandMillis (std::chrono::minutes{ 5 } );
1499
+ const std::chrono::milliseconds delta = 10min + GetRandMillis (5min );
1500
1500
scheduler.scheduleFromNow ([&] { ReattemptInitialBroadcast (scheduler); }, delta);
1501
1501
}
1502
1502
@@ -1963,10 +1963,9 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
1963
1963
std::vector<CInv> vNotFound;
1964
1964
const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
1965
1965
1966
- const std::chrono::seconds now = GetTime<std::chrono::seconds>();
1966
+ const auto now{ GetTime<std::chrono::seconds>()} ;
1967
1967
// Get last mempool request time
1968
- const std::chrono::seconds mempool_req = pfrom.m_tx_relay != nullptr ? pfrom.m_tx_relay ->m_last_mempool_req .load ()
1969
- : std::chrono::seconds::min ();
1968
+ const auto mempool_req = pfrom.m_tx_relay != nullptr ? pfrom.m_tx_relay ->m_last_mempool_req .load () : std::chrono::seconds::min ();
1970
1969
1971
1970
// Process as many TX items from the front of the getdata queue as
1972
1971
// possible, since they're common and it's efficient to batch process
@@ -2890,7 +2889,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2890
2889
int64_t nSince = nNow - 10 * 60 ;
2891
2890
2892
2891
// Update/increment addr rate limiting bucket.
2893
- const auto current_time = GetTime<std::chrono::microseconds>();
2892
+ const auto current_time{ GetTime<std::chrono::microseconds>()} ;
2894
2893
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
2895
2894
// Don't increment bucket if it's already full
2896
2895
const auto time_diff = std::max (current_time - peer->m_addr_token_timestamp , 0us);
@@ -2976,7 +2975,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
2976
2975
2977
2976
LOCK (cs_main);
2978
2977
2979
- const auto current_time = GetTime<std::chrono::microseconds>();
2978
+ const auto current_time{ GetTime<std::chrono::microseconds>()} ;
2980
2979
uint256* best_block{nullptr };
2981
2980
2982
2981
for (CInv& inv : vInv) {
@@ -3354,7 +3353,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3354
3353
}
3355
3354
}
3356
3355
if (!fRejectedParents ) {
3357
- const auto current_time = GetTime<std::chrono::microseconds>();
3356
+ const auto current_time{ GetTime<std::chrono::microseconds>()} ;
3358
3357
3359
3358
for (const uint256& parent_txid : unique_parents) {
3360
3359
// Here, we only have the txid (and not wtxid) of the
@@ -4571,7 +4570,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4571
4570
// If we get here, the outgoing message serialization version is set and can't change.
4572
4571
const CNetMsgMaker msgMaker (pto->GetCommonVersion ());
4573
4572
4574
- const auto current_time = GetTime<std::chrono::microseconds>();
4573
+ const auto current_time{ GetTime<std::chrono::microseconds>()} ;
4575
4574
4576
4575
if (pto->IsAddrFetchConn () && current_time - pto->m_connected > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
4577
4576
LogPrint (BCLog::NET, " addrfetch connection timeout; disconnecting peer=%d\n " , pto->GetId ());
0 commit comments