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

fix: Statistics seconds counter #348

Merged
merged 4 commits into from
Jan 6, 2025
Merged

fix: Statistics seconds counter #348

merged 4 commits into from
Jan 6, 2025

Conversation

tuliomir
Copy link
Contributor

@tuliomir tuliomir commented Dec 16, 2024

In the new interface, the timer does not update when the number of txs or the blocks height change. An example of the timer is as follows:

Timer

A new version of this screen has changed the counter to the title element, instead of inside each of the realtime boxes, as follows:
New interface

Acceptance Criteria

  • The seconds counter should be updated only when the best block height changes

Notes

The current implementation is still not precise, because the time property of the dashboard:metrics websocket event received has no relation to the best block or transaction data.

This screen should rely on the information received through the websocket as it is now, but the server-side implementation of this event should be changed in the future to provide more precise information here.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@tuliomir tuliomir added the bug Something isn't working label Dec 16, 2024
@tuliomir tuliomir self-assigned this Dec 16, 2024
@tuliomir tuliomir requested a review from r4mmer as a code owner December 16, 2024 15:04
r4mmer
r4mmer previously approved these changes Dec 16, 2024
Comment on lines 44 to 49
setSummary({
bestBlockHeight: heightData.best_block_height,
transactions: heightData.transactions,
hashRate: heightData.hash_rate,
});
setTimestamp(new Date(heightData.time * 1000));
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to set this if you can use the data from redux directly?

I think if you use heightData directly you could remove the whole useEffect.

Choose a reason for hiding this comment

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

As a complement to Pedro's comment, you can track change looking only to the value of best_block_height, not the whole object of heightData.

Copy link
Contributor Author

@tuliomir tuliomir Dec 18, 2024

Choose a reason for hiding this comment

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

Thanks, always good to remove local state from components!

The useEffect was still necessary, as the websocket implementation that provides the height data is not ideal for our needs.

However, the effect now deals exclusively with the time counter data, and not the exhibited values, see 5c6299b.

@tuliomir tuliomir merged commit 3d618bc into master Jan 6, 2025
1 check passed
@tuliomir tuliomir deleted the fix/seconds-counter branch January 6, 2025 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants