p2p: count pending static dials toward the dial demand - #1017
Open
hyunsooda wants to merge 1 commit into
Open
Conversation
getCandidates derived the dynamic demand from the connected and dialing counts, then appended the static nodes without touching that demand, so statics dialed in the same batch were invisible to it and the outbound count for their type settled at the target plus the number of statics of that type. Nothing trims the excess afterwards, and a warm discovery table on restart is enough to reach it. The demand now drops by every static that is about to be dialed, which is what the function comment already claims: you don't need dynamic candidates when you have enough static nodes. Constraint: the subtraction runs under the read lock getCandidates already holds, so shouldDial was split into a lock-free dialEligible rather than re-entering the lock Constraint: only statics passing dialEligible are subtracted; connected or dialing ones are already in the counts that produced the demand Rejected: Make the dynamic dial reservation atomic | dialLoop is a single goroutine running getCandidates and launchDialTasks in sequence, so there is no window to close Confidence: high Scope-risk: narrow Not-tested: a dead static delaying its dynamic replacement by one dial timeout Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Proposed changes
getCandidatescomputes the dynamic dial demand before appending the staticnodes, so statics dialed in the same batch go uncounted and the outbound count
for their type settles at
target + statics. The demand now drops by everystatic about to be dialed.
Types of changes
Checklist
$ make test)Further comments
Only statics passing
dialEligibleare subtracted — connected or dialing onesalready sit in the counts.
shouldDialwas split so that check can run underthe read lock
getCandidatesalready holds.