refactor(p2p): enable goimports and varcheck linters #16446#2005
refactor(p2p): enable goimports and varcheck linters #16446#2005AnilChinchawale merged 1 commit intoXinFinOrg:dev-upgradefrom
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 You can disable this status message by setting the
✨ 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
Enables/cleans up code to satisfy goimports and varcheck in the p2p/discv5 area by removing unused symbols and adjusting generated string conversion code.
Changes:
- Removed unused devp2p message code constants in
p2p/peer.go. - Removed unused imports/test variables in
p2p/discv5/udp_test.goand an unused constant inp2p/discv5/table.go. - Updated
p2p/discv5/nodeevent_string.gostring conversion logic fornodeEvent.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| p2p/peer.go | Drops unused message code constants. |
| p2p/discv5/udp_test.go | Removes unused time import and unused shared test vars. |
| p2p/discv5/table.go | Removes an unused constant. |
| p2p/discv5/nodeevent_string.go | Modifies nodeEvent.String() implementation (currently incorrect). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| i -= 264 | ||
| if i >= nodeEvent(len(_nodeEvent_index)-1) { | ||
| return "nodeEvent(" + strconv.FormatInt(int64(i+264), 10) + ")" | ||
| } | ||
| return _nodeEvent_name[_nodeEvent_index[i]:_nodeEvent_index[i+1]] |
There was a problem hiding this comment.
nodeEvent.String() implementation is incorrect after this change: i -= 264 misaligns the timeout constants (e.g., pongTimeout is 265) and will underflow for packet event values (<264), producing wrong names/IDs (and potentially negative-looking values after uint->int64 conversion). This should be regenerated with stringer -type=nodeEvent (or restored to logic that correctly handles both ranges 0..8 and 265..267) rather than manually trimming the generated output.
| i -= 264 | |
| if i >= nodeEvent(len(_nodeEvent_index)-1) { | |
| return "nodeEvent(" + strconv.FormatInt(int64(i+264), 10) + ")" | |
| } | |
| return _nodeEvent_name[_nodeEvent_index[i]:_nodeEvent_index[i+1]] | |
| switch i { | |
| case pongTimeout: | |
| return "pongTimeout" | |
| case pingTimeout: | |
| return "pingTimeout" | |
| case neighboursTimeout: | |
| return "neighboursTimeout" | |
| default: | |
| return "nodeEvent(" + strconv.FormatInt(int64(i), 10) + ")" | |
| } |
2d586c1 to
88a6ffd
Compare
Proposed changes
Ref: ethereum#16446
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
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