fix(service-disco): wait time cap#2834
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2834 +/- ##
=======================================
Coverage 81.23% 81.23%
=======================================
Files 170 170
Lines 30750 30750
Branches 13 12 -1
=======================================
+ Hits 24979 24981 +2
+ Misses 5771 5769 -2
🚀 New features to boost your workflow:
|
SionoiS
marked this pull request as ready for review
July 15, 2026 15:53
gmelodie
approved these changes
Jul 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Service Discovery registrar behavior by capping computed wait times to advertExpiry (so the registrar never asks an advertiser to wait longer than the advert’s own lifetime) and by making registration() use second-level time granularity consistently.
Changes:
- Clamp
waitingTime()’s returnedDurationto<= discoConfig.advertExpiry. - Replace the
max/minpair with a singleclamp()call for bounding the floating-point wait value. - Quantize
registration()’snowtimestamp to whole seconds and add tests covering both the wait cap and the timestamp granularity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
libp2p/protocols/service_discovery/registrar.nim |
Adds an advertExpiry cap to waitingTime() and truncates registration()’s now to whole-second granularity. |
tests/libp2p/service_discovery/test_registrar.nim |
Adds coverage for the advertExpiry cap behavior and verifies second-granularity timestamps emitted by registration(). |
richard-ramos
approved these changes
Jul 15, 2026
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.
A much better version of #2825
Thanks @jm-clius