Skip to content

Commit 2364d17

Browse files
committed
Merge bitcoin#25480: Replace CountSecondsDouble with Ticks<SecondsDouble>
fa956e7 Replace CountSecondsDouble with Ticks<SecondsDouble> (MacroFake) Pull request description: Seems odd to have two ways to say exactly the same thing when one is sufficient. ACKs for top commit: fanquake: ACK fa956e7 shaavan: ACK fa956e7 w0xlt: ACK bitcoin@fa956e7 Tree-SHA512: b599470e19b693da1ed1102d1e86b08cb03adaddf2048752b6d050fdf86055be117ff0ae10b6953d03e00eaaf7b0cfa350137968b67d6c5b3ca68c5aa50ca6aa
2 parents bace615 + fa956e7 commit 2364d17

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
@@ -3019,7 +3019,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
30193019
if (peer->m_addr_token_bucket < MAX_ADDR_PROCESSING_TOKEN_BUCKET) {
30203020
// Don't increment bucket if it's already full
30213021
const auto time_diff = std::max(current_time - peer->m_addr_token_timestamp, 0us);
3022-
const double increment = CountSecondsDouble(time_diff) * MAX_ADDR_RATE_PER_SECOND;
3022+
const double increment = Ticks<SecondsDouble>(time_diff) * MAX_ADDR_RATE_PER_SECOND;
30233023
peer->m_addr_token_bucket = std::min<double>(peer->m_addr_token_bucket + increment, MAX_ADDR_PROCESSING_TOKEN_BUCKET);
30243024
}
30253025
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)