mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin#23832: Changes time variables from int to chrono
includes:
- fe86eb50c986f7b5ccce63f984d8a51cd9ee9e2c
continuation of 9399f90a
in dash#6097
This commit is contained in:
parent
06bf649e1b
commit
9aacee78ae
@ -78,11 +78,11 @@ static constexpr int32_t MAX_PEER_OBJECT_IN_FLIGHT = 100;
|
||||
/** Maximum number of announced objects from a peer */
|
||||
static constexpr int32_t MAX_PEER_OBJECT_ANNOUNCEMENTS = 2 * MAX_INV_SZ;
|
||||
/** How many microseconds to delay requesting transactions from inbound peers */
|
||||
static constexpr std::chrono::microseconds INBOUND_PEER_TX_DELAY{std::chrono::seconds{2}};
|
||||
/** How long to wait (in microseconds) before downloading a transaction from an additional peer */
|
||||
static constexpr std::chrono::microseconds GETDATA_TX_INTERVAL{std::chrono::seconds{60}};
|
||||
/** Maximum delay (in microseconds) for transaction requests to avoid biasing some peers over others. */
|
||||
static constexpr std::chrono::microseconds MAX_GETDATA_RANDOM_DELAY{std::chrono::seconds{2}};
|
||||
static constexpr auto INBOUND_PEER_TX_DELAY{2s};
|
||||
/** How long to wait before downloading a transaction from an additional peer */
|
||||
static constexpr auto GETDATA_TX_INTERVAL{60s};
|
||||
/** Maximum delay for transaction requests to avoid biasing some peers over others. */
|
||||
static constexpr auto MAX_GETDATA_RANDOM_DELAY{2s};
|
||||
/** How long to wait (expiry * factor microseconds) before expiring an in-flight getdata request to a peer */
|
||||
static constexpr int64_t TX_EXPIRY_INTERVAL_FACTOR = 10;
|
||||
static_assert(INBOUND_PEER_TX_DELAY >= MAX_GETDATA_RANDOM_DELAY,
|
||||
@ -111,7 +111,7 @@ static constexpr auto STALE_CHECK_INTERVAL{150s}; // 2.5 minutes (~block interva
|
||||
/** How frequently to check for extra outbound peers and disconnect */
|
||||
static constexpr auto EXTRA_PEER_CHECK_INTERVAL{45s};
|
||||
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict */
|
||||
static constexpr std::chrono::seconds MINIMUM_CONNECT_TIME{30};
|
||||
static constexpr auto MINIMUM_CONNECT_TIME{30s};
|
||||
/** SHA256("main address relay")[0:8] */
|
||||
static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL;
|
||||
/// Age after which a stale block will no longer be served if requested as
|
||||
@ -121,7 +121,7 @@ static constexpr int STALE_RELAY_AGE_LIMIT = 30 * 24 * 60 * 60;
|
||||
/// limiting block relay. Set to one week, denominated in seconds.
|
||||
static constexpr int HISTORICAL_BLOCK_AGE = 7 * 24 * 60 * 60;
|
||||
/** Time between pings automatically sent out for latency probing and keepalive */
|
||||
static constexpr std::chrono::minutes PING_INTERVAL{2};
|
||||
static constexpr auto PING_INTERVAL{2min};
|
||||
/** The maximum number of entries in a locator */
|
||||
static const unsigned int MAX_LOCATOR_SZ = 101;
|
||||
/** Number of blocks that can be requested at any given time from a single peer. */
|
||||
@ -152,17 +152,17 @@ static const int MAX_UNCONNECTING_HEADERS = 10;
|
||||
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */
|
||||
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
|
||||
/** Average delay between local address broadcasts */
|
||||
static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24h;
|
||||
static constexpr auto AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{24h};
|
||||
/** Average delay between peer address broadcasts */
|
||||
static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL = 30s;
|
||||
static constexpr auto AVG_ADDRESS_BROADCAST_INTERVAL{30s};
|
||||
/** Average delay between trickled inventory transmissions for inbound peers.
|
||||
* Blocks and peers with NetPermissionFlags::NoBan permission bypass this. */
|
||||
static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL = 5s;
|
||||
static constexpr auto INBOUND_INVENTORY_BROADCAST_INTERVAL{5s};
|
||||
/** Average delay between trickled inventory transmissions for outbound peers.
|
||||
* Use a smaller delay as there is less privacy concern for them.
|
||||
* Blocks and peers with NetPermissionFlags::NoBan permission bypass this.
|
||||
* Masternode outbound peers get half this delay. */
|
||||
static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL = 2s;
|
||||
static constexpr auto OUTBOUND_INVENTORY_BROADCAST_INTERVAL{2s};
|
||||
/** Maximum rate of inventory items to send per second.
|
||||
* Limits the impact of low-fee transaction floods.
|
||||
* We have 4 times smaller block times in Dash, so we need to push 4 times more invs per 1MB. */
|
||||
@ -458,7 +458,7 @@ struct CNodeState {
|
||||
* - its chain tip has at least as much work as ours
|
||||
*
|
||||
* CHAIN_SYNC_TIMEOUT: if a peer's best known block has less work than our tip,
|
||||
* set a timeout CHAIN_SYNC_TIMEOUT seconds in the future:
|
||||
* set a timeout CHAIN_SYNC_TIMEOUT in the future:
|
||||
* - If at timeout their best known block now has more work than our tip
|
||||
* when the timeout was set, then either reset the timeout or clear it
|
||||
* (after comparing against our current tip's work)
|
||||
@ -1477,11 +1477,11 @@ std::chrono::microseconds GetObjectInterval(int invType)
|
||||
switch(invType)
|
||||
{
|
||||
case MSG_QUORUM_RECOVERED_SIG:
|
||||
return std::chrono::seconds{15};
|
||||
return 15s;
|
||||
case MSG_CLSIG:
|
||||
return std::chrono::seconds{5};
|
||||
return 5s;
|
||||
case MSG_ISDLOCK:
|
||||
return std::chrono::seconds{10};
|
||||
return 10s;
|
||||
default:
|
||||
return GETDATA_TX_INTERVAL;
|
||||
}
|
||||
@ -1604,7 +1604,7 @@ void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
|
||||
|
||||
// Schedule next run for 10-15 minutes in the future.
|
||||
// We add randomness on every cycle to avoid the possibility of P2P fingerprinting.
|
||||
const std::chrono::milliseconds delta = std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5});
|
||||
const std::chrono::milliseconds delta = 10min + GetRandMillis(5min);
|
||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
|
||||
}
|
||||
|
||||
@ -1706,7 +1706,7 @@ bool PeerManagerImpl::GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) c
|
||||
// since pingtime does not update until the ping is complete, which might take a while.
|
||||
// So, if a ping is taking an unusually long time in flight,
|
||||
// the caller can immediately detect that this is happening.
|
||||
std::chrono::microseconds ping_wait{0};
|
||||
auto ping_wait{0us};
|
||||
if ((0 != peer->m_ping_nonce_sent) && (0 != peer->m_ping_start.load().count())) {
|
||||
ping_wait = GetTime<std::chrono::microseconds>() - peer->m_ping_start.load();
|
||||
}
|
||||
@ -1947,7 +1947,7 @@ void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler)
|
||||
scheduler.scheduleEvery([this] { this->CheckForStaleTipAndEvictPeers(); }, std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL});
|
||||
|
||||
// schedule next run for 10-15 minutes in the future
|
||||
const std::chrono::milliseconds delta = std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5});
|
||||
const std::chrono::milliseconds delta = 10min + GetRandMillis(5min);
|
||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
|
||||
}
|
||||
|
||||
@ -2558,10 +2558,10 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
|
||||
std::vector<CInv> vNotFound;
|
||||
const CNetMsgMaker msgMaker(pfrom.GetCommonVersion());
|
||||
|
||||
const std::chrono::seconds now = GetTime<std::chrono::seconds>();
|
||||
const auto now{GetTime<std::chrono::seconds>()};
|
||||
// Get last mempool request time
|
||||
const std::chrono::seconds mempool_req = tx_relay != nullptr ? tx_relay->m_last_mempool_req.load()
|
||||
: std::chrono::seconds::min();
|
||||
const auto mempool_req = tx_relay != nullptr ? tx_relay->m_last_mempool_req.load()
|
||||
: std::chrono::seconds::min();
|
||||
|
||||
// Process as many TX items from the front of the getdata queue as
|
||||
// possible, since they're common and it's efficient to batch process
|
||||
@ -3782,7 +3782,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
int64_t nSince = nNow - 10 * 60;
|
||||
|
||||
// Update/increment addr rate limiting bucket.
|
||||
const auto current_time = GetTime<std::chrono::microseconds>();
|
||||
const auto current_time{GetTime<std::chrono::microseconds>()};
|
||||
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
|
||||
// Don't increment bucket if it's already full
|
||||
const auto time_diff = std::max(current_time - peer->m_addr_token_timestamp, 0us);
|
||||
@ -3877,7 +3877,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
const auto current_time = GetTime<std::chrono::microseconds>();
|
||||
const auto current_time{GetTime<std::chrono::microseconds>()};
|
||||
uint256* best_block{nullptr};
|
||||
|
||||
for (CInv& inv : vInv) {
|
||||
@ -4315,7 +4315,7 @@ void PeerManagerImpl::ProcessMessage(
|
||||
}
|
||||
}
|
||||
if (!fRejectedParents) {
|
||||
const auto current_time = GetTime<std::chrono::microseconds>();
|
||||
const auto current_time{GetTime<std::chrono::microseconds>()};
|
||||
|
||||
for (const uint256& parent_txid : unique_parents) {
|
||||
CInv _inv(MSG_TX, parent_txid);
|
||||
@ -5573,7 +5573,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
||||
// If we get here, the outgoing message serialization version is set and can't change.
|
||||
const CNetMsgMaker msgMaker(pto->GetCommonVersion());
|
||||
|
||||
const auto current_time = GetTime<std::chrono::microseconds>();
|
||||
const auto current_time{GetTime<std::chrono::microseconds>()};
|
||||
|
||||
if (pto->IsAddrFetchConn() && current_time - pto->m_connected > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
|
||||
LogPrint(BCLog::NET_NETCONN, "addrfetch connection timeout; disconnecting peer=%d\n", pto->GetId());
|
||||
|
Loading…
Reference in New Issue
Block a user