mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 07:37:20 +00:00
eth/protocols/eth: fix handshake timeout metrics classification (#33539)
Previously, handshake timeouts were recorded as generic peer errors instead of timeout errors. waitForHandshake passed a raw p2p.DiscReadTimeout into markError, but markError classified errors only via errors.Unwrap(err), which returns nil for non-wrapped errors. As a result, the timeoutError meter was never incremented and all such failures fell into the peerError bucket. This change makes markError switch on the base error, using errors.Unwrap(err) when available and falling back to the original error otherwise. With this adjustment, p2p.DiscReadTimeout is correctly mapped to timeoutError, while existing behaviour for the other wrapped sentinel errors remains unchanged --------- Co-authored-by: lightclient <lightclient@protonmail.com>
This commit is contained in:
parent
8450e40798
commit
2a45272408
1 changed files with 6 additions and 6 deletions
|
|
@ -191,16 +191,16 @@ func markError(p *Peer, err error) {
|
|||
return
|
||||
}
|
||||
m := meters.get(p.Inbound())
|
||||
switch errors.Unwrap(err) {
|
||||
case errNetworkIDMismatch:
|
||||
switch {
|
||||
case errors.Is(err, errNetworkIDMismatch):
|
||||
m.networkIDMismatch.Mark(1)
|
||||
case errProtocolVersionMismatch:
|
||||
case errors.Is(err, errProtocolVersionMismatch):
|
||||
m.protocolVersionMismatch.Mark(1)
|
||||
case errGenesisMismatch:
|
||||
case errors.Is(err, errGenesisMismatch):
|
||||
m.genesisMismatch.Mark(1)
|
||||
case errForkIDRejected:
|
||||
case errors.Is(err, errForkIDRejected):
|
||||
m.forkidRejected.Mark(1)
|
||||
case p2p.DiscReadTimeout:
|
||||
case errors.Is(err, p2p.DiscReadTimeout):
|
||||
m.timeoutError.Mark(1)
|
||||
default:
|
||||
m.peerError.Mark(1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue