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

Replace int with std::chrono in for the timer->setInterval() argument #524

Merged
merged 1 commit into from Feb 4, 2022

Conversation

shaavan
Copy link
Contributor

@shaavan shaavan commented Jan 12, 2022

The PR is a follow-up to #517

  • It addresses the change suggested in this comment.
  • This PR changes the type of msecsPerSample from int to std::chrono::minutes and makes other relevant subsequent changes that were limited to the trafficgraphwidget file.

src/qt/trafficgraphwidget.h Outdated Show resolved Hide resolved
src/qt/trafficgraphwidget.h Outdated Show resolved Hide resolved
src/qt/trafficgraphwidget.cpp Outdated Show resolved Hide resolved
@shaavan
Copy link
Contributor Author

shaavan commented Jan 13, 2022

Updated from 6e947e6 to 9bb48bf (pr524.01 -> pr524.02)
Addressed @hebasto comments

Changes:

  • Changed argument type of setGraphRangeMins from int to std::minutes.
  • setGraphRangeMins -> setGraphRange; getGraphRangeMins -> getGraphRange
  • Moved nMins to member initialization.
  • Renamed nMins -> m_range.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 13, 2022

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #539 (gui: scale network graph based on time interval by RandyMcMillan)
  • #492 (Show ToolTip on Network Traffic graph by rebroad)
  • #484 (Don't clear traffic graph when changing interval by rebroad)

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.

Copy link
Contributor

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

Concept ACK

src/qt/rpcconsole.cpp Outdated Show resolved Hide resolved
src/qt/trafficgraphwidget.cpp Outdated Show resolved Hide resolved
src/qt/trafficgraphwidget.cpp Outdated Show resolved Hide resolved
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Tested 9bb48bf on Linux Mint 20.3 (Qt 5.12.8) -- the "Network Traffic" tab shows a black window.

@shaavan
Copy link
Contributor Author

shaavan commented Jan 16, 2022

Updated from 9bb48bf to 5e6ad43 (pr524.02 -> pr524.03)
Addressed @jonatack and @hebasto’s suggestions.

  • Done proper casting of m_range variable from mins to milliseconds.
  • Used duration_casting instead of static_casting, as suggested by @hebasto. The reason for doing so is explained in this article.
  • Incorporated other nit suggestions.

Tested that the network traffic graph is working correctly now.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

Approach ACK 5e6ad43, tested on Linux Mint 20.3 (Qt 5.12.8).

About commit message:

src/qt/trafficgraphwidget.cpp Outdated Show resolved Hide resolved
src/qt/trafficgraphwidget.cpp Outdated Show resolved Hide resolved
@shaavan
Copy link
Contributor Author

shaavan commented Jan 18, 2022

Updated from 5e6ad43 to f7a19ef (pr524.03 -> pr524.04)
Addressed @hebasto suggestions

Changes:

  • Removed the redundant using namespace std::chrono_literals; statement.
  • Removed unnecessary type conversion of chrono::minutes variable.
  • Renamed mins -> new_range.
  • Made appropriate changes to commit message as suggested here.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

ACK f7a19ef

@RandyMcMillan
Copy link
Contributor

tACK f7a19ef

on MacOS x86_64 and Arm64

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Code review ACK f7a19ef.

@@ -22,22 +24,22 @@ class TrafficGraphWidget : public QWidget
public:
explicit TrafficGraphWidget(QWidget *parent = nullptr);
void setClientModel(ClientModel *model);
int getGraphRangeMins() const;
std::chrono::minutes getGraphRange() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just remove? It's not used.

Copy link
Contributor

Choose a reason for hiding this comment

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

@promag @shaavan

I concur - It appears to be part of the original implementation but never used for anything...

it can and should be removed...

https://github.com/bitcoin-core/gui/blame/16781e1bc9f8ffc721ebea73434e0066957bc959/src/qt/trafficgraphwidget.cpp#L45

Screen Shot 2022-01-20 at 1 16 34 PM

Copy link
Contributor

Choose a reason for hiding this comment

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

@promag - great catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @promag for catching this. Addressed in 5efd391

Copy link
Contributor

Choose a reason for hiding this comment

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

Approach ACK Removing the TrafficGraphWidget::getGraphRangeMins() function nACK

I use int TrafficGraphWidget::getGraphRangeMins() const in PR #539 (which fixes issue #532)

I have added a variation to of this PR to #539 c25d3f4 to ensure compatibility with the chrono lib.

Note

https://github.com/bitcoin-core/gui/pull/524/files#diff-da38549cd85e0c422891b8ef1eb3cc33e76f0b80d15ca63aa7ad6f065c8ba694L44

@shaavan
Copy link
Contributor Author

shaavan commented Jan 21, 2022

Updated from f7a19ef to 5efd391 (pr524.04 -> pr524.05)
Addressed @promag suggestions

Changes:

  • Removed the unused function getGraphRange() from the TrafficGraphWidget class.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

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

tACK 5efd391 on Ubuntu 21.10 (Qt 5.15.2).

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

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

re-ACK 5efd391

@shaavan
Copy link
Contributor Author

shaavan commented Jan 27, 2022

Updated from 5efd391 to bdf7cb9 (pr524.05 -> pr524.06)
Addressed @promag suggestion

Changes:

  • Removed m_range as a member variable of the class TrafficGraphWidget and replaced it with a local range variable.

@RandyMcMillan
Copy link
Contributor

Approach ACK
Removing the TrafficGraphWidget::getGraphRangeMins() function nACK

I use int TrafficGraphWidget::getGraphRangeMins() const in PR #539 (which fixes issue #532)

I have added a variation to of this PR to #539 c25d3f4 to ensure compatibility with the chrono lib.

Note

https://github.com/bitcoin-core/gui/pull/524/files#diff-da38549cd85e0c422891b8ef1eb3cc33e76f0b80d15ca63aa7ad6f065c8ba694L44

@shaavan
Copy link
Contributor Author

shaavan commented Jan 31, 2022

I use int TrafficGraphWidget::getGraphRangeMins() const in PR #539 (which fixes issue #532)

I looked through #532, but I couldn't find any use case of getGraphRangeMins() there. So I don't think there should be an issue removing this function in this PR.

I have added a variation of this PR to #539 c25d3f4 to ensure compatibility with the chrono lib.

I looked through it, and it looked good. However, I reckon the primary purpose of #539 is to fix an issue by adding a scaling feature. And the purpose of this PR is refactoring. So I think it would be best to keep these PRs separate.

@RandyMcMillan
Copy link
Contributor

If you insist - but to scale the graph - we will have to know the current value of the slider - otherwise the graph can't calculate how many samples to display. It will have to be re-added - it is easier to leave it in.

#539

@shaavan
Copy link
Contributor Author

shaavan commented Feb 1, 2022

It will have to be re-added - it is easier to leave it in.

I think you are right. Let me keep the GetGraphRange() function and make it consistent with the previous changes.

@shaavan
Copy link
Contributor Author

shaavan commented Feb 3, 2022

Updated from bdf7cb9 to cad0e0a (pr524.06 -> pr524.07, diff)
Addressed @RandyMcMillan comment

Changes:

The updated PR correctly compiles on Ubuntu 20.04, with the Network Traffic widget showing the correct graph.

@shaavan
Copy link
Contributor Author

shaavan commented Feb 3, 2022

Reverted back to f7a19ef (pr524.07 -> pr524.04, diff)

Reason:

P.S.: To avoid any unintended changes between the PR and f7a19ef, I used the following command to update the PR:

git reset --hard HEAD^
git cherry-pick f7a19ef774ef92ce348215593e3590a750c345e1

The commit id has changed (which I was not able to restore) but the changes are identical f7a19ef

@shaavan
Copy link
Contributor Author

shaavan commented Feb 4, 2022

Restored PR to previous commit f7a19ef. The reason for doing so is explained here: #524 (comment)

P.s.: Thanks, @hebasto, for your help in restoring this commit.

@hebasto hebasto merged commit 5c6b3d5 into bitcoin-core:master Feb 4, 2022
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 6, 2022
@RandyMcMillan
Copy link
Contributor

@shaavan - thanks for leaving that function in - @rebroad and I have work that utilizes this.

@shaavan shaavan deleted the 220112-chrono branch February 9, 2022 10:37
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Feb 9, 2023
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

8 participants