mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 04:12:36 -03:00
Replace CountSecondsDouble with Ticks<SecondsDouble>
This commit is contained in:
parent
dde7205c57
commit
fa956e7508
3 changed files with 4 additions and 9 deletions
|
@ -3015,7 +3015,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
|
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
|
||||||
// Don't increment bucket if it's already full
|
// Don't increment bucket if it's already full
|
||||||
const auto time_diff = std::max(current_time - peer->m_addr_token_timestamp, 0us);
|
const auto time_diff = std::max(current_time - peer->m_addr_token_timestamp, 0us);
|
||||||
const double increment = CountSecondsDouble(time_diff) * MAX_ADDR_RATE_PER_SECOND;
|
const double increment = Ticks<SecondsDouble>(time_diff) * MAX_ADDR_RATE_PER_SECOND;
|
||||||
peer->m_addr_token_bucket = std::min<double>(peer->m_addr_token_bucket + increment, MAX_ADDR_PROCESSING_TOKEN_BUCKET);
|
peer->m_addr_token_bucket = std::min<double>(peer->m_addr_token_bucket + increment, MAX_ADDR_PROCESSING_TOKEN_BUCKET);
|
||||||
}
|
}
|
||||||
peer->m_addr_token_timestamp = current_time;
|
peer->m_addr_token_timestamp = current_time;
|
||||||
|
|
|
@ -206,13 +206,13 @@ static RPCHelpMan getpeerinfo()
|
||||||
obj.pushKV("conntime", count_seconds(stats.m_connected));
|
obj.pushKV("conntime", count_seconds(stats.m_connected));
|
||||||
obj.pushKV("timeoffset", stats.nTimeOffset);
|
obj.pushKV("timeoffset", stats.nTimeOffset);
|
||||||
if (stats.m_last_ping_time > 0us) {
|
if (stats.m_last_ping_time > 0us) {
|
||||||
obj.pushKV("pingtime", CountSecondsDouble(stats.m_last_ping_time));
|
obj.pushKV("pingtime", Ticks<SecondsDouble>(stats.m_last_ping_time));
|
||||||
}
|
}
|
||||||
if (stats.m_min_ping_time < std::chrono::microseconds::max()) {
|
if (stats.m_min_ping_time < std::chrono::microseconds::max()) {
|
||||||
obj.pushKV("minping", CountSecondsDouble(stats.m_min_ping_time));
|
obj.pushKV("minping", Ticks<SecondsDouble>(stats.m_min_ping_time));
|
||||||
}
|
}
|
||||||
if (fStateStats && statestats.m_ping_wait > 0s) {
|
if (fStateStats && statestats.m_ping_wait > 0s) {
|
||||||
obj.pushKV("pingwait", CountSecondsDouble(statestats.m_ping_wait));
|
obj.pushKV("pingwait", Ticks<SecondsDouble>(statestats.m_ping_wait));
|
||||||
}
|
}
|
||||||
obj.pushKV("version", stats.nVersion);
|
obj.pushKV("version", stats.nVersion);
|
||||||
// Use the sanitized form of subver here, to avoid tricksy remote peers from
|
// Use the sanitized form of subver here, to avoid tricksy remote peers from
|
||||||
|
|
|
@ -56,11 +56,6 @@ constexpr int64_t count_microseconds(std::chrono::microseconds t) { return t.cou
|
||||||
|
|
||||||
using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period>;
|
using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper to count the seconds in any std::chrono::duration type
|
|
||||||
*/
|
|
||||||
inline double CountSecondsDouble(SecondsDouble t) { return t.count(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DEPRECATED
|
* DEPRECATED
|
||||||
* Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
|
* Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
|
||||||
|
|
Loading…
Reference in a new issue