Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
9d9e2a3b
Commit
9d9e2a3b
authored
Jan 13, 2015
by
Juan Batiz-Benet
Browse files
p2p/net/swarm: configurable timeout for tests
parent
3d3ffc45
Changes
2
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm.go
View file @
9d9e2a3b
...
...
@@ -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
...
...
net/swarm/swarm_dial.go
View file @
9d9e2a3b
...
...
@@ -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