File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ func markDialError(err error) {
68
68
return
69
69
}
70
70
71
+ var e * protoHandshakeError
71
72
switch {
72
73
case errors .Is (err , DiscTooManyPeers ):
73
74
dialTooManyPeers .Mark (1 )
@@ -81,7 +82,7 @@ func markDialError(err error) {
81
82
dialUnexpectedIdentity .Mark (1 )
82
83
case errors .Is (err , errEncHandshakeError ):
83
84
dialEncHandshakeError .Mark (1 )
84
- case errors .Is (err , errProtoHandshakeError ):
85
+ case errors .As (err , & e ):
85
86
dialProtoHandshakeError .Mark (1 )
86
87
}
87
88
}
Original file line number Diff line number Diff line change @@ -66,11 +66,15 @@ const (
66
66
)
67
67
68
68
var (
69
- errServerStopped = errors .New ("server stopped" )
70
- errEncHandshakeError = errors .New ("rlpx enc error" )
71
- errProtoHandshakeError = errors .New ("rlpx proto error" )
69
+ errServerStopped = errors .New ("server stopped" )
70
+ errEncHandshakeError = errors .New ("rlpx enc error" )
72
71
)
73
72
73
+ type protoHandshakeError struct { err error }
74
+
75
+ func (e * protoHandshakeError ) Error () string { return fmt .Sprintf ("rlpx proto error: %s" , e .err ) }
76
+ func (e * protoHandshakeError ) Unwrap () error { return e .err }
77
+
74
78
// Server manages all peer connections.
75
79
type Server struct {
76
80
// Config fields may not be modified while the server is running.
@@ -908,7 +912,7 @@ func (srv *Server) setupConn(c *conn, dialDest *enode.Node) error {
908
912
if err != nil {
909
913
clog .Trace ("Failed p2p handshake" , "err" , err )
910
914
//Wrapping both errors for later inspection
911
- return fmt . Errorf ( "%w: %w" , errProtoHandshakeError , err )
915
+ return & protoHandshakeError { err : err }
912
916
}
913
917
if id := c .node .ID (); ! bytes .Equal (crypto .Keccak256 (phs .ID ), id [:]) {
914
918
clog .Trace ("Wrong devp2p handshake identity" , "phsid" , hex .EncodeToString (phs .ID ))
You can’t perform that action at this time.
0 commit comments