mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
fix dial metrics not picking up the right error
The original error was not wrapped, so the caller function had no chance of picking it up. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
80753ba147
commit
f5e0eadad2
2 changed files with 11 additions and 12 deletions
|
|
@ -67,23 +67,21 @@ func markDialError(err error) {
|
|||
if !metrics.Enabled() {
|
||||
return
|
||||
}
|
||||
if err2 := errors.Unwrap(err); err2 != nil {
|
||||
err = err2
|
||||
}
|
||||
switch err {
|
||||
case DiscTooManyPeers:
|
||||
|
||||
switch {
|
||||
case errors.Is(err, DiscTooManyPeers):
|
||||
dialTooManyPeers.Mark(1)
|
||||
case DiscAlreadyConnected:
|
||||
case errors.Is(err, DiscAlreadyConnected):
|
||||
dialAlreadyConnected.Mark(1)
|
||||
case DiscSelf:
|
||||
case errors.Is(err, DiscSelf):
|
||||
dialSelf.Mark(1)
|
||||
case DiscUselessPeer:
|
||||
case errors.Is(err, DiscUselessPeer):
|
||||
dialUselessPeer.Mark(1)
|
||||
case DiscUnexpectedIdentity:
|
||||
case errors.Is(err, DiscUnexpectedIdentity):
|
||||
dialUnexpectedIdentity.Mark(1)
|
||||
case errEncHandshakeError:
|
||||
case errors.Is(err, errEncHandshakeError):
|
||||
dialEncHandshakeError.Mark(1)
|
||||
case errProtoHandshakeError:
|
||||
case errors.Is(err, errProtoHandshakeError):
|
||||
dialProtoHandshakeError.Mark(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -907,7 +907,8 @@ func (srv *Server) setupConn(c *conn, dialDest *enode.Node) error {
|
|||
phs, err := c.doProtoHandshake(srv.ourHandshake)
|
||||
if err != nil {
|
||||
clog.Trace("Failed p2p handshake", "err", err)
|
||||
return fmt.Errorf("%w: %v", errProtoHandshakeError, err)
|
||||
//Wrapping both errors for later inspection
|
||||
return fmt.Errorf("%w: %w", errProtoHandshakeError, err)
|
||||
}
|
||||
if id := c.node.ID(); !bytes.Equal(crypto.Keccak256(phs.ID), id[:]) {
|
||||
clog.Trace("Wrong devp2p handshake identity", "phsid", hex.EncodeToString(phs.ID))
|
||||
|
|
|
|||
Loading…
Reference in a new issue