Skip to content

Commit fa956e7

Browse files
author
MacroFake
committed
Replace CountSecondsDouble with Ticks<SecondsDouble>
1 parent dde7205 commit fa956e7

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3015,7 +3015,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
30153015
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
30163016
// Don't increment bucket if it's already full
30173017
const auto time_diff = std::max(current_time - peer->m_addr_token_timestamp, 0us);
3018-
const double increment = CountSecondsDouble(time_diff) * MAX_ADDR_RATE_PER_SECOND;
3018+
const double increment = Ticks<SecondsDouble>(time_diff) * MAX_ADDR_RATE_PER_SECOND;
30193019
peer->m_addr_token_bucket = std::min<double>(peer->m_addr_token_bucket + increment, MAX_ADDR_PROCESSING_TOKEN_BUCKET);
30203020
}
30213021
peer->m_addr_token_timestamp = current_time;

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,13 @@ static RPCHelpMan getpeerinfo()
206206
obj.pushKV("conntime", count_seconds(stats.m_connected));
207207
obj.pushKV("timeoffset", stats.nTimeOffset);
208208
if (stats.m_last_ping_time > 0us) {
209-
obj.pushKV("pingtime", CountSecondsDouble(stats.m_last_ping_time));
209+
obj.pushKV("pingtime", Ticks<SecondsDouble>(stats.m_last_ping_time));
210210
}
211211
if (stats.m_min_ping_time < std::chrono::microseconds::max()) {
212-
obj.pushKV("minping", CountSecondsDouble(stats.m_min_ping_time));
212+
obj.pushKV("minping", Ticks<SecondsDouble>(stats.m_min_ping_time));
213213
}
214214
if (fStateStats && statestats.m_ping_wait > 0s) {
215-
obj.pushKV("pingwait", CountSecondsDouble(statestats.m_ping_wait));
215+
obj.pushKV("pingwait", Ticks<SecondsDouble>(statestats.m_ping_wait));
216216
}
217217
obj.pushKV("version", stats.nVersion);
218218
// Use the sanitized form of subver here, to avoid tricksy remote peers from

src/util/time.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ constexpr int64_t count_microseconds(std::chrono::microseconds t) { return t.cou
5656

5757
using SecondsDouble = std::chrono::duration<double, std::chrono::seconds::period>;
5858

59-
/**
60-
* Helper to count the seconds in any std::chrono::duration type
61-
*/
62-
inline double CountSecondsDouble(SecondsDouble t) { return t.count(); }
63-
6459
/**
6560
* DEPRECATED
6661
* Use either ClockType::now() or Now<TimePointType>() if a cast is needed.

0 commit comments

Comments
 (0)