Commit f4bb4313 authored by Steven Allen's avatar Steven Allen

feat(dial): implement the Timeout interface on dial errors

parent 5efa2fa2
......@@ -2,6 +2,7 @@ package swarm
import (
"fmt"
"os"
"strings"
"github.com/libp2p/go-libp2p-core/peer"
......@@ -20,6 +21,10 @@ type DialError struct {
Skipped int
}
func (e *DialError) Timeout() bool {
return os.IsTimeout(e.Cause)
}
func (e *DialError) recordErr(addr ma.Multiaddr, err error) {
if len(e.DialErrors) >= maxDialDialErrors {
e.Skipped++
......@@ -48,11 +53,7 @@ func (e *DialError) Error() string {
// Unwrap implements https://godoc.org/golang.org/x/xerrors#Wrapper.
func (e *DialError) Unwrap() error {
// If we have a context error, that's the "ultimate" error.
if e.Cause != nil {
return e.Cause
}
return nil
return e.Cause
}
var _ error = (*DialError)(nil)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment