aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorneedkane <604476380@qq.com>2018-12-01 05:38:37 +0800
committerFelix Lange <fjl@users.noreply.github.com>2018-12-01 05:38:37 +0800
commit54abb97e3be4fb2d6f557758aaa3a8291b0979fe (patch)
treea990c4c204df95efe6bbd9d621b33bbc179627d7
parentef8ced4151006c84e77ab8db88cf6fc1bb09a716 (diff)
downloaddexon-54abb97e3be4fb2d6f557758aaa3a8291b0979fe.tar.gz
dexon-54abb97e3be4fb2d6f557758aaa3a8291b0979fe.tar.zst
dexon-54abb97e3be4fb2d6f557758aaa3a8291b0979fe.zip
p2p: use errors.New instead of fmt.Errorf (#18193)
-rw-r--r--p2p/server.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/p2p/server.go b/p2p/server.go
index 667860863..566f01ffc 100644
--- a/p2p/server.go
+++ b/p2p/server.go
@@ -22,7 +22,6 @@ import (
"crypto/ecdsa"
"encoding/hex"
"errors"
- "fmt"
"net"
"sort"
"sync"
@@ -391,7 +390,7 @@ type sharedUDPConn struct {
func (s *sharedUDPConn) ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error) {
packet, ok := <-s.unhandled
if !ok {
- return 0, nil, fmt.Errorf("Connection was closed")
+ return 0, nil, errors.New("Connection was closed")
}
l := len(packet.Data)
if l > len(b) {
@@ -425,7 +424,7 @@ func (srv *Server) Start() (err error) {
// static fields
if srv.PrivateKey == nil {
- return fmt.Errorf("Server.PrivateKey must be set to a non-nil key")
+ return errors.New("Server.PrivateKey must be set to a non-nil key")
}
if srv.newTransport == nil {
srv.newTransport = newRLPX
@@ -903,7 +902,7 @@ func (srv *Server) setupConn(c *conn, flags connFlag, dialDest *enode.Node) erro
if dialDest != nil {
dialPubkey = new(ecdsa.PublicKey)
if err := dialDest.Load((*enode.Secp256k1)(dialPubkey)); err != nil {
- return fmt.Errorf("dial destination doesn't have a secp256k1 public key")
+ return errors.New("dial destination doesn't have a secp256k1 public key")
}
}
// Run the encryption handshake.
@@ -937,7 +936,7 @@ func (srv *Server) setupConn(c *conn, flags connFlag, dialDest *enode.Node) erro
return err
}
if id := c.node.ID(); !bytes.Equal(crypto.Keccak256(phs.ID), id[:]) {
- clog.Trace("Wrong devp2p handshake identity", "phsid", fmt.Sprintf("%x", phs.ID))
+ clog.Trace("Wrong devp2p handshake identity", "phsid", hex.EncodeToString(phs.ID))
return DiscUnexpectedIdentity
}
c.caps, c.name = phs.Caps, phs.Name