Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-swarm
Commits
f4bb4313
Commit
f4bb4313
authored
Nov 04, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dial): implement the Timeout interface on dial errors
parent
5efa2fa2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
dial_error.go
dial_error.go
+6
-5
No files found.
dial_error.go
View file @
f4bb4313
...
...
@@ -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
}
var
_
error
=
(
*
DialError
)(
nil
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment