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
580a818b
Commit
580a818b
authored
Mar 31, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge dial contexts where possible
parent
e7b6af60
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
swarm_dial.go
swarm_dial.go
+17
-0
No files found.
swarm_dial.go
View file @
580a818b
...
...
@@ -320,6 +320,7 @@ func (s *Swarm) dialWorkerLoop(ctx context.Context, p peer.ID, reqch <-chan Dial
conn
*
Conn
err
error
requests
[]
int
dialed
bool
}
reqno
:=
0
...
...
@@ -454,6 +455,9 @@ loop:
requests
[
reqno
]
=
pr
for
_
,
ad
:=
range
tojoin
{
if
!
ad
.
dialed
{
ad
.
ctx
=
s
.
mergeDialContexts
(
ad
.
ctx
,
req
.
Ctx
)
}
ad
.
requests
=
append
(
ad
.
requests
,
reqno
)
}
...
...
@@ -490,6 +494,7 @@ loop:
continue
}
ad
.
dialed
=
true
dialed
=
true
last
=
i
active
++
...
...
@@ -581,6 +586,18 @@ func (s *Swarm) addrsForDial(ctx context.Context, p peer.ID) ([]ma.Multiaddr, er
return
goodAddrs
,
nil
}
func
(
s
*
Swarm
)
mergeDialContexts
(
a
,
b
context
.
Context
)
context
.
Context
{
dialCtx
:=
a
if
simConnect
,
reason
:=
network
.
GetSimultaneousConnect
(
b
);
simConnect
{
if
simConnect
,
_
:=
network
.
GetSimultaneousConnect
(
a
);
!
simConnect
{
dialCtx
=
network
.
WithSimultaneousConnect
(
dialCtx
,
reason
)
}
}
return
dialCtx
}
func
(
s
*
Swarm
)
dialNextAddr
(
ctx
context
.
Context
,
p
peer
.
ID
,
addr
ma
.
Multiaddr
,
resch
chan
dialResult
)
error
{
// check the dial backoff
if
forceDirect
,
_
:=
network
.
GetForceDirectDial
(
ctx
);
!
forceDirect
{
...
...
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