build: enable goimports and varcheck linters (#16446)

This commit is contained in:
thomasmodeneis
2018-04-18 00:53:50 +02:00
committed by Felix Lange
parent 7605e63cb9
commit ba1030b6b8
28 changed files with 54 additions and 98 deletions

View File

@ -36,7 +36,6 @@ import (
var (
errInvalidEvent = errors.New("invalid in current state")
errNoQuery = errors.New("no pending query")
errWrongAddress = errors.New("unknown sender address")
)
const (
@ -828,11 +827,10 @@ type nodeEvent uint
//go:generate 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

@ -4,24 +4,14 @@ package discv5
import "strconv"
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 0 <= i && 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

@ -36,25 +36,17 @@ const Version = 4
// Errors
var (
errPacketTooSmall = errors.New("too small")
errBadPrefix = errors.New("bad prefix")
errExpired = errors.New("expired")
errUnsolicitedReply = errors.New("unsolicited reply")
errUnknownNode = errors.New("unknown node")
errTimeout = errors.New("RPC timeout")
errClockWarp = errors.New("reply deadline too far in the future")
errClosed = errors.New("socket closed")
errPacketTooSmall = errors.New("too small")
errBadPrefix = errors.New("bad prefix")
errTimeout = errors.New("RPC timeout")
)
// Timeouts
const (
respTimeout = 500 * time.Millisecond
queryDelay = 1000 * time.Millisecond
expiration = 20 * time.Second
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
ntpWarningCooldown = 10 * time.Minute // Minimum amount of time to pass before repeating NTP warning
driftThreshold = 10 * time.Second // Allowed clock drift before warning user
driftThreshold = 10 * time.Second // Allowed clock drift before warning user
)
// RPC request structures

View File

@ -24,7 +24,6 @@ import (
"reflect"
"sync"
"testing"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
@ -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 {