mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
p2p: fix unused warnings (#1804)
This commit is contained in:
parent
6450d5bbb9
commit
0aeb971b33
9 changed files with 6 additions and 153 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ var (
|
|||
nodeDBDiscoverPing = nodeDBDiscoverRoot + ":lastping"
|
||||
nodeDBDiscoverPong = nodeDBDiscoverRoot + ":lastpong"
|
||||
nodeDBDiscoverFindFails = nodeDBDiscoverRoot + ":findfail"
|
||||
nodeDBDiscoverLocalEndpoint = nodeDBDiscoverRoot + ":localendpoint"
|
||||
nodeDBTopicRegTickets = ":tickets"
|
||||
)
|
||||
|
||||
|
|
@ -311,20 +310,6 @@ func (db *nodeDB) updateFindFails(id NodeID, fails int) error {
|
|||
return db.storeInt64(makeKey(id, nodeDBDiscoverFindFails), int64(fails))
|
||||
}
|
||||
|
||||
// localEndpoint returns the last local endpoint communicated to the
|
||||
// given remote node.
|
||||
func (db *nodeDB) localEndpoint(id NodeID) *rpcEndpoint {
|
||||
var ep rpcEndpoint
|
||||
if err := db.fetchRLP(makeKey(id, nodeDBDiscoverLocalEndpoint), &ep); err != nil {
|
||||
return nil
|
||||
}
|
||||
return &ep
|
||||
}
|
||||
|
||||
func (db *nodeDB) updateLocalEndpoint(id NodeID, ep rpcEndpoint) error {
|
||||
return db.storeRLP(makeKey(id, nodeDBDiscoverLocalEndpoint), &ep)
|
||||
}
|
||||
|
||||
// querySeeds retrieves random nodes to be used as potential seed nodes
|
||||
// for bootstrapping.
|
||||
func (db *nodeDB) querySeeds(n int, maxAge time.Duration) []*Node {
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
@ -78,14 +77,6 @@ type Network struct {
|
|||
nursery []*Node
|
||||
nodes map[NodeID]*Node // tracks active nodes with state != known
|
||||
timeoutTimers map[timeoutEvent]*time.Timer
|
||||
|
||||
// Revalidation queues.
|
||||
// Nodes put on these queues will be pinged eventually.
|
||||
slowRevalidateQueue []*Node
|
||||
fastRevalidateQueue []*Node
|
||||
|
||||
// Buffers for state transition.
|
||||
sendBuf []*ingressPacket
|
||||
}
|
||||
|
||||
// transport is implemented by the UDP transport.
|
||||
|
|
|
|||
|
|
@ -265,10 +265,6 @@ type preminedTestnet struct {
|
|||
net *Network
|
||||
}
|
||||
|
||||
func (tn *preminedTestnet) sendFindnode(to *Node, target NodeID) {
|
||||
panic("sendFindnode called")
|
||||
}
|
||||
|
||||
func (tn *preminedTestnet) sendFindnodeHash(to *Node, target common.Hash) {
|
||||
// current log distance is encoded in port number
|
||||
// fmt.Println("findnode query at dist", toaddr.Port)
|
||||
|
|
@ -316,10 +312,6 @@ func (tn *preminedTestnet) sendNeighbours(to *Node, nodes []*Node) {
|
|||
panic("sendNeighbours called")
|
||||
}
|
||||
|
||||
func (tn *preminedTestnet) sendTopicQuery(to *Node, topic Topic) {
|
||||
panic("sendTopicQuery called")
|
||||
}
|
||||
|
||||
func (tn *preminedTestnet) sendTopicNodes(to *Node, queryHash common.Hash, nodes []*Node) {
|
||||
panic("sendTopicNodes called")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ import (
|
|||
type nullTransport struct{}
|
||||
|
||||
func (nullTransport) sendPing(remote *Node, remoteAddr *net.UDPAddr) []byte { return []byte{1} }
|
||||
func (nullTransport) sendPong(remote *Node, pingHash []byte) {}
|
||||
func (nullTransport) sendFindnode(remote *Node, target NodeID) {}
|
||||
func (nullTransport) sendNeighbours(remote *Node, nodes []*Node) {}
|
||||
func (nullTransport) localAddr() *net.UDPAddr { return new(net.UDPAddr) }
|
||||
func (nullTransport) Close() {}
|
||||
|
|
@ -159,28 +157,6 @@ func nodeAtDistance(base common.Hash, ld int) (n *Node) {
|
|||
return n
|
||||
}
|
||||
|
||||
type pingRecorder struct{ responding, pinged map[NodeID]bool }
|
||||
|
||||
func newPingRecorder() *pingRecorder {
|
||||
return &pingRecorder{make(map[NodeID]bool), make(map[NodeID]bool)}
|
||||
}
|
||||
|
||||
func (t *pingRecorder) findnode(toid NodeID, toaddr *net.UDPAddr, target NodeID) ([]*Node, error) {
|
||||
panic("findnode called on pingRecorder")
|
||||
}
|
||||
func (t *pingRecorder) close() {}
|
||||
func (t *pingRecorder) waitping(from NodeID) error {
|
||||
return nil // remote always pings
|
||||
}
|
||||
func (t *pingRecorder) ping(toid NodeID, toaddr *net.UDPAddr) error {
|
||||
t.pinged[toid] = true
|
||||
if t.responding[toid] {
|
||||
return nil
|
||||
} else {
|
||||
return errTimeout
|
||||
}
|
||||
}
|
||||
|
||||
func TestTable_closest(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
|||
|
|
@ -36,25 +36,16 @@ 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
|
||||
respTimeout = 500 * time.Millisecond
|
||||
expiration = 20 * time.Second
|
||||
driftThreshold = 10 * time.Second // Allowed clock drift before warning user
|
||||
)
|
||||
|
||||
// RPC request structures
|
||||
|
|
@ -195,10 +186,6 @@ func makeEndpoint(addr *net.UDPAddr, tcpPort uint16) rpcEndpoint {
|
|||
return rpcEndpoint{IP: ip, UDP: uint16(addr.Port), TCP: tcpPort}
|
||||
}
|
||||
|
||||
func (e1 rpcEndpoint) equal(e2 rpcEndpoint) bool {
|
||||
return e1.UDP == e2.UDP && e1.TCP == e2.TCP && e1.IP.Equal(e2.IP)
|
||||
}
|
||||
|
||||
func nodeFromRPC(sender *net.UDPAddr, rn rpcNode) (*Node, error) {
|
||||
if err := netutil.CheckRelayIP(sender.IP, rn.IP); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -281,13 +268,6 @@ func (t *udp) sendPing(remote *Node, toaddr *net.UDPAddr, topics []Topic) (hash
|
|||
return hash
|
||||
}
|
||||
|
||||
func (t *udp) sendFindnode(remote *Node, target NodeID) {
|
||||
t.sendPacket(remote.ID, remote.addr(), byte(findnodePacket), findnode{
|
||||
Target: target,
|
||||
Expiration: uint64(time.Now().Add(expiration).Unix()),
|
||||
})
|
||||
}
|
||||
|
||||
func (t *udp) sendNeighbours(remote *Node, results []*Node) {
|
||||
// Send neighbors in chunks with at most maxNeighbors per packet
|
||||
// to stay below the 1280 byte limit.
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
// Copyright 2017 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package protocols
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/p2p/discover"
|
||||
)
|
||||
|
||||
// handshake message type
|
||||
type hs0 struct {
|
||||
C uint
|
||||
}
|
||||
|
||||
// message to kill/drop the peer with nodeID
|
||||
type kill struct {
|
||||
C discover.NodeID
|
||||
}
|
||||
|
||||
// message to drop connection
|
||||
type drop struct {
|
||||
}
|
||||
|
||||
// / protoHandshake represents module-independent aspects of the protocol and is
|
||||
// the first message peers send and receive as part the initial exchange
|
||||
type protoHandshake struct {
|
||||
Version uint // local and remote peer should have identical version
|
||||
NetworkID string // local and remote peer should have identical network id
|
||||
}
|
||||
|
||||
// checkProtoHandshake verifies local and remote protoHandshakes match
|
||||
func checkProtoHandshake(testVersion uint, testNetworkID string) func(interface{}) error {
|
||||
return func(rhs interface{}) error {
|
||||
remote := rhs.(*protoHandshake)
|
||||
if remote.NetworkID != testNetworkID {
|
||||
return fmt.Errorf("%s (!= %s)", remote.NetworkID, testNetworkID)
|
||||
}
|
||||
|
||||
if remote.Version != testVersion {
|
||||
return fmt.Errorf("%d (!= %d)", remote.Version, testVersion)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
10
p2p/rlpx.go
10
p2p/rlpx.go
|
|
@ -429,16 +429,6 @@ func (h *encHandshake) makeAuthResp() (msg *authRespV4, err error) {
|
|||
return msg, nil
|
||||
}
|
||||
|
||||
func (msg *authMsgV4) sealPlain(h *encHandshake) ([]byte, error) {
|
||||
buf := make([]byte, authMsgLen)
|
||||
n := copy(buf, msg.Signature[:])
|
||||
n += copy(buf[n:], crypto.Keccak256(exportPubkey(&h.randomPrivKey.PublicKey)))
|
||||
n += copy(buf[n:], msg.InitiatorPubkey[:])
|
||||
n += copy(buf[n:], msg.Nonce[:])
|
||||
buf[n] = 0 // token-flag
|
||||
return ecies.Encrypt(rand.Reader, h.remotePub, buf, nil, nil)
|
||||
}
|
||||
|
||||
func (msg *authMsgV4) decodePlain(input []byte) {
|
||||
n := copy(msg.Signature[:], input)
|
||||
n += shaLen // skip sha3(initiator-ephemeral-pubk)
|
||||
|
|
|
|||
Loading…
Reference in a new issue