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
dms3
go-dms3
Commits
9689b280
Commit
9689b280
authored
Jan 13, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/net/swarm: configurable timeout for tests
parent
af889dc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
p2p/net/swarm/swarm.go
p2p/net/swarm/swarm.go
+4
-0
p2p/net/swarm/swarm_dial.go
p2p/net/swarm/swarm_dial.go
+2
-2
No files found.
p2p/net/swarm/swarm.go
View file @
9689b280
...
...
@@ -4,6 +4,7 @@ package swarm
import
(
"fmt"
"time"
inet
"github.com/jbenet/go-ipfs/p2p/net"
addrutil
"github.com/jbenet/go-ipfs/p2p/net/swarm/addr"
...
...
@@ -32,8 +33,10 @@ type Swarm struct {
local
peer
.
ID
peers
peer
.
Peerstore
connh
ConnHandler
dsync
dialsync
backf
dialbackoff
dialT
time
.
Duration
// mainly for tests
cg
ctxgroup
.
ContextGroup
}
...
...
@@ -55,6 +58,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
local
:
local
,
peers
:
peers
,
cg
:
ctxgroup
.
WithContext
(
ctx
),
dialT
:
DialTimeout
,
}
// configure Swarm
...
...
p2p/net/swarm/swarm_dial.go
View file @
9689b280
...
...
@@ -210,7 +210,7 @@ func (s *Swarm) Dial(ctx context.Context, p peer.ID) (*Conn, error) {
// ok, we have been charged to dial! let's do it.
// if it succeeds, dial will add the conn to the swarm itself.
log
.
Debugf
(
"dial start"
)
ctxT
,
_
:=
context
.
WithTimeout
(
ctx
,
D
ialT
imeout
)
ctxT
,
_
:=
context
.
WithTimeout
(
ctx
,
s
.
d
ialT
)
conn
,
err
=
s
.
dial
(
ctxT
,
p
)
s
.
dsync
.
Unlock
(
p
)
log
.
Debugf
(
"dial end %s"
,
conn
)
...
...
@@ -264,7 +264,7 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
d
:=
&
conn
.
Dialer
{
Dialer
:
manet
.
Dialer
{
Dialer
:
net
.
Dialer
{
Timeout
:
D
ialT
imeout
,
Timeout
:
s
.
d
ialT
,
},
},
LocalPeer
:
s
.
local
,
...
...
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