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
65768db0
Commit
65768db0
authored
Jan 13, 2015
by
Juan Batiz-Benet
Browse files
p2p/net/swarm: const dial attempts
parent
51f1fc34
Changes
1
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm_dial.go
View file @
65768db0
...
...
@@ -14,6 +14,9 @@ import (
ma
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
)
// dialAttempts governs how many times a goroutine will try to dial a given peer.
const
dialAttempts
=
3
// dialsync is a small object that helps manage ongoing dials.
// this way, if we receive many simultaneous dial requests, one
// can do its thing, while the rest wait.
...
...
@@ -101,11 +104,10 @@ func (s *Swarm) Dial(ctx context.Context, p peer.ID) (*Conn, error) {
// to check s.ConnectionsToPeer(p) _first_, and _between_ attempts because we
// may have received an incoming connection! if so, we no longer must dial.
//
// dial attempts. we may be doing the dialing. if not, we wait.
attempts
:=
3
// During the dial attempts, we may be doing the dialing. if not, we wait.
var
err
error
var
conn
*
Conn
for
i
:=
0
;
i
<
a
ttempts
;
i
++
{
for
i
:=
0
;
i
<
dialA
ttempts
;
i
++
{
// check if we already have an open connection first
cs
:=
s
.
ConnectionsToPeer
(
p
)
for
_
,
conn
=
range
cs
{
...
...
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