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
Hide 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
...
@@ -2,6 +2,7 @@ package swarm
import
(
import
(
"fmt"
"fmt"
"os"
"strings"
"strings"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peer"
...
@@ -20,6 +21,10 @@ type DialError struct {
...
@@ -20,6 +21,10 @@ type DialError struct {
Skipped
int
Skipped
int
}
}
func
(
e
*
DialError
)
Timeout
()
bool
{
return
os
.
IsTimeout
(
e
.
Cause
)
}
func
(
e
*
DialError
)
recordErr
(
addr
ma
.
Multiaddr
,
err
error
)
{
func
(
e
*
DialError
)
recordErr
(
addr
ma
.
Multiaddr
,
err
error
)
{
if
len
(
e
.
DialErrors
)
>=
maxDialDialErrors
{
if
len
(
e
.
DialErrors
)
>=
maxDialDialErrors
{
e
.
Skipped
++
e
.
Skipped
++
...
@@ -48,11 +53,7 @@ func (e *DialError) Error() string {
...
@@ -48,11 +53,7 @@ func (e *DialError) Error() string {
// Unwrap implements https://godoc.org/golang.org/x/xerrors#Wrapper.
// Unwrap implements https://godoc.org/golang.org/x/xerrors#Wrapper.
func
(
e
*
DialError
)
Unwrap
()
error
{
func
(
e
*
DialError
)
Unwrap
()
error
{
// If we have a context error, that's the "ultimate" error.
return
e
.
Cause
if
e
.
Cause
!=
nil
{
return
e
.
Cause
}
return
nil
}
}
var
_
error
=
(
*
DialError
)(
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