refactor(p2p/discover): improve table addition code #18974#2367
refactor(p2p/discover): improve table addition code #18974#2367gzliudan wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the discovery table’s node addition logic to distinguish between “seen” nodes (unverified) and “verified” nodes, improving how nodes are inserted/updated in buckets and updating associated tests accordingly.
Changes:
- Replace the previous generic table add path with
addSeenNode(append to bucket / add as replacement) andaddVerifiedNode(bump/add to front with init-safety). - Update bucket bumping to handle endpoint/IP changes while respecting IP limits.
- Adjust discovery UDP ping handling and update/add tests to cover the new behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| p2p/discover/udp.go | Switch ping handler to the new verified-node insertion path. |
| p2p/discover/table.go | Introduce addSeenNode/addVerifiedNode, refactor bump logic, and add a shared contains helper. |
| p2p/discover/table_util_test.go | Update test helpers to use the new add API. |
| p2p/discover/table_test.go | Update existing tests and add new ones for addSeenNode/addVerifiedNode and IP-limit invariants. |
2a22297 to
fe2e450
Compare
Proposed changes
Ref: ethereum#18974
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that