aboutsummaryrefslogtreecommitdiffstats
path: root/p2p
diff options
context:
space:
mode:
authorthomasmodeneis <thomas.modeneis@gmail.com>2018-04-18 06:53:50 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-04-18 06:53:50 +0800
commitba1030b6b84f810c04a82221a1b1c0a3dbf499a8 (patch)
tree9c3450535acddfec3b1987e0a2e04fa9ca303e38 /p2p
parent7605e63cb9dda7fc5bb619abf1eb1f74ac3f6cc1 (diff)
downloaddexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar.gz
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar.bz2
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar.lz
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar.xz
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.tar.zst
dexon-ba1030b6b84f810c04a82221a1b1c0a3dbf499a8.zip
build: enable goimports and varcheck linters (#16446)
Diffstat (limited to 'p2p')
-rw-r--r--p2p/discover/udp.go1
-rw-r--r--p2p/discv5/net.go4
-rw-r--r--p2p/discv5/nodeevent_string.go22
-rw-r--r--p2p/discv5/table.go1
-rw-r--r--p2p/discv5/udp.go16
-rw-r--r--p2p/discv5/udp_test.go7
-rw-r--r--p2p/enr/enr.go1
-rw-r--r--p2p/peer.go2
8 files changed, 12 insertions, 42 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go
index 524c6e498..f6bcd9708 100644
--- a/p2p/discover/udp.go
+++ b/p2p/discover/udp.go
@@ -49,7 +49,6 @@ var (
// Timeouts
const (
respTimeout = 500 * time.Millisecond
- sendTimeout = 500 * time.Millisecond
expiration = 20 * time.Second
ntpFailureThreshold = 32 // Continuous timeouts after which to check NTP
diff --git a/p2p/discv5/net.go b/p2p/discv5/net.go
index 52c677b62..9b0bd0c80 100644
--- a/p2p/discv5/net.go
+++ b/p2p/discv5/net.go
@@ -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
diff --git a/p2p/discv5/nodeevent_string.go b/p2p/discv5/nodeevent_string.go
index eb696fb8b..38c1993ba 100644
--- a/p2p/discv5/nodeevent_string.go
+++ b/p2p/discv5/nodeevent_string.go
@@ -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]]
}
diff --git a/p2p/discv5/table.go b/p2p/discv5/table.go
index 2cf05009c..c8d234b93 100644
--- a/p2p/discv5/table.go
+++ b/p2p/discv5/table.go
@@ -38,7 +38,6 @@ const (
hashBits = len(common.Hash{}) * 8
nBuckets = hashBits + 1 // Number of buckets
- maxBondingPingPongs = 16
maxFindnodeFailures = 5
)
diff --git a/p2p/discv5/udp.go b/p2p/discv5/udp.go
index 6ce72d2c1..09e5f8b37 100644
--- a/p2p/discv5/udp.go
+++ b/p2p/discv5/udp.go
@@ -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
diff --git a/p2p/discv5/udp_test.go b/p2p/discv5/udp_test.go
index 7d3181594..62184aa9d 100644
--- a/p2p/discv5/udp_test.go
+++ b/p2p/discv5/udp_test.go
@@ -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 {
diff --git a/p2p/enr/enr.go b/p2p/enr/enr.go
index 2c3afb43e..c018895cc 100644
--- a/p2p/enr/enr.go
+++ b/p2p/enr/enr.go
@@ -46,7 +46,6 @@ const ID_SECP256k1_KECCAK = ID("secp256k1-keccak") // the default identity schem
var (
errNoID = errors.New("unknown or unspecified identity scheme")
- errInvalidSigsize = errors.New("invalid signature size")
errInvalidSig = errors.New("invalid signature")
errNotSorted = errors.New("record key/value pairs are not sorted by key")
errDuplicateKey = errors.New("record contains duplicate key")
diff --git a/p2p/peer.go b/p2p/peer.go
index 477d8c219..73e33418e 100644
--- a/p2p/peer.go
+++ b/p2p/peer.go
@@ -47,8 +47,6 @@ const (
discMsg = 0x01
pingMsg = 0x02
pongMsg = 0x03
- getPeersMsg = 0x04
- peersMsg = 0x05
)
// protoHandshake is the RLP structure of the protocol handshake.