This changes various uses of integers to represent timestamps and durations to std::chrono duration types with type-safe conversions, getting rid of various .count(), constructors, and conversion factors.
Builds on #20027.
Concept ACK
Concept ACK.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Concept ACK. Is it worth waiting for C++17 and switching directly to chrono literals (eg https://en.cppreference.com/w/cpp/chrono/operator%22%22h)?
Concept ACK. Is it worth waiting for C++17 and switching directly to chrono literals (eg https://en.cppreference.com/w/cpp/chrono/operator%22%22h)?
That would be nice, but it's also kind of an independent improvement (there are a bunch of time durations constants in the code that aren't touched by this PR).
I don't like waiting for C++17, as we don't actually know when that may happen. I saw there were some issues with using C++17's std::filesystem, which may push things back for example (I may be mistaken here, but in general I don't like a "We shouldn't do X yet, because we expect that Soon(tm) we will be able to do it better").
in general I don't like a "We shouldn't do X yet, because we expect that Soon(tm) we will be able to do it better"
I totally agree, but in this case I thought Soon(tm) was about 4 weeks from now when 0.21 is branched (https://github.com/bitcoin/bitcoin/issues/18947) and master moves onto C++17 (https://github.com/bitcoin/bitcoin/issues/16684). Is that still the plan?
I totally agree, but in this case I thought Soon(tm) was about 4 weeks from now when 0.21 is branched (#18947) and master moves onto C++17 (#16684). Is that still the plan?
Oh that's fair. I don't know why I was conflating "not being able to use certain C++17 features like std::filesystem" with "not being able to switch compilation to C++17".
Concept ACK
182 | @@ -183,14 +183,14 @@ static RPCHelpMan getpeerinfo() 183 | obj.pushKV("bytesrecv", stats.nRecvBytes); 184 | obj.pushKV("conntime", stats.nTimeConnected); 185 | obj.pushKV("timeoffset", stats.nTimeOffset); 186 | - if (stats.m_ping_usec > 0) { 187 | - obj.pushKV("pingtime", ((double)stats.m_ping_usec) / 1e6); 188 | + if (stats.m_ping_time.count() > 0) { 189 | + obj.pushKV("pingtime", count_microseconds(stats.m_ping_time) * 0.000001);
* 1e-6 ?
<!--cf906140f33d8803c4a75a2196329ecb-->
🐙 This pull request conflicts with the target branch and needs rebase.
<sub>Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".</sub>
Still needs rebase. Let me know if this is up for grabs.
Hmm, apparently I started a review of this at some point and got distracted?
Concept ACK
@sipa Weekly ping to ask whether this is up for grabs :)
This is up for grabs.
I'll take a swing at rebasing this code shortly.