Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all of net_processing (and some of net) use std::chrono types #20044

Closed
wants to merge 5 commits into from

Conversation

sipa
Copy link
Member

@sipa sipa commented Sep 30, 2020

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.

@fanquake
Copy link
Member

Concept ACK

@naumenkogs
Copy link
Member

Concept ACK.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 30, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

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.

@jnewbery
Copy link
Contributor

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)?

@maflcko
Copy link
Member

maflcko commented Sep 30, 2020

@sipa
Copy link
Member Author

sipa commented Sep 30, 2020

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").

@jnewbery
Copy link
Contributor

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 (#18947) and master moves onto C++17 (#16684). Is that still the plan?

@sipa
Copy link
Member Author

sipa commented Sep 30, 2020

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".

@practicalswift
Copy link
Contributor

Concept ACK

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 8, 2020

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@maflcko
Copy link
Member

maflcko commented Jan 15, 2021

Still needs rebase. Let me know if this is up for grabs.

Copy link
Contributor

@ajtowns ajtowns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, apparently I started a review of this at some point and got distracted?

Concept ACK

if (stats.m_ping_usec > 0) {
obj.pushKV("pingtime", ((double)stats.m_ping_usec) / 1e6);
if (stats.m_ping_time.count() > 0) {
obj.pushKV("pingtime", count_microseconds(stats.m_ping_time) * 0.000001);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* 1e-6 ?

@maflcko
Copy link
Member

maflcko commented Jan 21, 2021

@sipa Weekly ping to ask whether this is up for grabs :)

@jnewbery
Copy link
Contributor

This is up for grabs.

@dhruv
Copy link
Contributor

dhruv commented Jan 26, 2021

I'll take a swing at rebasing this code shortly.

@vasild
Copy link
Contributor

vasild commented Jan 26, 2021

@dhruv Excellent! I subscribe as reviewer :)

@dhruv
Copy link
Contributor

dhruv commented Jan 27, 2021

#21015 is ready for review.

fanquake added a commit that referenced this pull request Mar 4, 2021
…hrono types

0eaea66 Make tx relay data structure use std::chrono types (Pieter Wuille)
55e8288 Make all Poisson delays use std::chrono types (Pieter Wuille)
c733ac4 Convert block/header sync timeouts to std::chrono types (Pieter Wuille)
4d98b40 Change all ping times to std::chrono types (Pieter Wuille)

Pull request description:

  (Picking up #20044. Rebased against master.)

  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.

ACKs for top commit:
  jnewbery:
    utACK 0eaea66
  vasild:
    ACK 0eaea66
  MarcoFalke:
    re-ACK 0eaea66, only changes: minor rename, using C++11 member initializer, using 2min chrono literal, rebase 🤚
  ajtowns:
    utACK 0eaea66

Tree-SHA512: 2dbd8d53bf82e98f9b4611e61dc14c448e8957d1a02575b837fadfd59f80e98614d0ccf890fc351f960ade76a6fb8051b282e252e81675a8ee753dba8b1d7f57
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants