Fix online reps weight sampling#4927
Merged
pwojcikdev merged 1 commit intonanocurrency:developfrom Jul 12, 2025
Merged
Conversation
Test Results for Commit a77d37bPull Request 4927: Results Test Case Results
Last updated: 2025-07-12 08:13:15 UTC |
c7ec75f to
a7ee511
Compare
a7ee511 to
a77d37b
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors how online representative weights are recalculated and sampled over time, ensuring updates happen both on new observations and within the background loop.
- Encapsulate online weight updates in a new
update_online()method and invoke it in bothobserve()and therun()loop. - Introduce
last_sampletimestamp inonline_reps.hppto gate trended weight sampling byweight_interval. - Update existing tests to use timed assertions and add a new test verifying online weight recalculation when a representative’s delegated weight changes.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| nano/node/online_reps.hpp | Added update_online() method and last_sample member for sampling |
| nano/node/online_reps.cpp | Implemented update_online(), adjusted run() loop timing and logic |
| nano/core_test/online_reps.cpp | Switched to ASSERT_TIMELY_EQ and added weight_change_recalculation test |
| nano/core_test/node.cpp | Introduced local delta variable in test and updated related asserts |
Comments suppressed due to low confidence (1)
nano/node/online_reps.hpp:103
- [nitpick] Consider adding a brief comment to explain that
last_sampletracks the timestamp of the last trended weight collection, improving readability and maintenance.
std::chrono::steady_clock::time_point last_sample;
pwojcikdev
added a commit
that referenced
this pull request
Jul 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.