refactor(p2p): enable goimports and varcheck linters #16446 (#2005)

This commit is contained in:
Daniel Liu 2026-02-06 15:53:25 +08:00 committed by GitHub
parent 9d79d44f1b
commit 5c2ac4d51c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 40 deletions

View file

@ -818,11 +818,9 @@ type nodeEvent uint
//go:generate go run golang.org/x/tools/cmd/stringer -type=nodeEvent
const (
invalidEvent nodeEvent = iota // zero is reserved
// Packet type events.
// These correspond to packet types in the UDP protocol.
pingPacket
pingPacket = iota + 1
pongPacket
findnodePacket
neighborsPacket

View file

@ -8,38 +8,19 @@ func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[invalidEvent-0]
_ = x[pingPacket-1]
_ = x[pongPacket-2]
_ = x[findnodePacket-3]
_ = x[neighborsPacket-4]
_ = x[findnodeHashPacket-5]
_ = x[topicRegisterPacket-6]
_ = x[topicQueryPacket-7]
_ = x[topicNodesPacket-8]
_ = x[pongTimeout-265]
_ = x[pingTimeout-266]
_ = x[neighboursTimeout-267]
_ = x[pongTimeout-264]
_ = x[pingTimeout-265]
_ = x[neighboursTimeout-266]
}
const (
_nodeEvent_name_0 = "invalidEventpingPacketpongPacketfindnodePacketneighborsPacketfindnodeHashPackettopicRegisterPackettopicQueryPackettopicNodesPacket"
_nodeEvent_name_1 = "pongTimeoutpingTimeoutneighboursTimeout"
)
const _nodeEvent_name = "pongTimeoutpingTimeoutneighboursTimeout"
var (
_nodeEvent_index_0 = [...]uint8{0, 12, 22, 32, 46, 61, 79, 98, 114, 130}
_nodeEvent_index_1 = [...]uint8{0, 11, 22, 39}
)
var _nodeEvent_index = [...]uint8{0, 11, 22, 39}
func (i nodeEvent) String() string {
switch {
case i <= 8:
return _nodeEvent_name_0[_nodeEvent_index_0[i]:_nodeEvent_index_0[i+1]]
case 265 <= i && i <= 267:
i -= 265
return _nodeEvent_name_1[_nodeEvent_index_1[i]:_nodeEvent_index_1[i+1]]
default:
return "nodeEvent(" + strconv.FormatInt(int64(i), 10) + ")"
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]]
}

View file

@ -38,7 +38,6 @@ const (
hashBits = len(common.Hash{}) * 8
nBuckets = hashBits + 1 // Number of buckets
maxBondingPingPongs = 16
maxFindnodeFailures = 5
)

View file

@ -24,7 +24,6 @@ import (
"reflect"
"sync"
"testing"
"time"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/crypto"
@ -38,11 +37,7 @@ func init() {
// shared test variables
var (
futureExp = uint64(time.Now().Add(10 * time.Hour).Unix())
testTarget = NodeID{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}
testRemote = rpcEndpoint{IP: net.ParseIP("1.1.1.1").To4(), UDP: 1, TCP: 2}
testLocalAnnounced = rpcEndpoint{IP: net.ParseIP("2.2.2.2").To4(), UDP: 3, TCP: 4}
testLocal = rpcEndpoint{IP: net.ParseIP("3.3.3.3").To4(), UDP: 5, TCP: 6}
testLocal = rpcEndpoint{IP: net.ParseIP("3.3.3.3").To4(), UDP: 5, TCP: 6}
)
// type udpTest struct {

View file

@ -49,8 +49,6 @@ const (
discMsg = 0x01
pingMsg = 0x02
pongMsg = 0x03
getPeersMsg = 0x04
peersMsg = 0x05
)
// protoHandshake is the RLP structure of the protocol handshake.