Skip to content

Commit

Permalink
p2p: reduce the scope of variable dialPubkey (ethereum#24385)
Browse files Browse the repository at this point in the history
dialPubkey isn't used anywhere else after dialDest.Load, so it should be safe to
restrict its scope to the if clause.
  • Loading branch information
zhiqiangxu authored and jagdeep sidhu committed Feb 14, 2022
1 parent c8e9d79 commit f0c1cf8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions p2p/server.go
Expand Up @@ -943,9 +943,8 @@ func (srv *Server) setupConn(c *conn, flags connFlag, dialDest *enode.Node) erro
}

// If dialing, figure out the remote public key.
var dialPubkey *ecdsa.PublicKey
if dialDest != nil {
dialPubkey = new(ecdsa.PublicKey)
dialPubkey := new(ecdsa.PublicKey)
if err := dialDest.Load((*enode.Secp256k1)(dialPubkey)); err != nil {
err = errors.New("dial destination doesn't have a secp256k1 public key")
srv.log.Trace("Setting up connection failed", "addr", c.fd.RemoteAddr(), "conn", c.flags, "err", err)
Expand Down

0 comments on commit f0c1cf8

Please sign in to comment.