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
4a69fa2f
Commit
4a69fa2f
authored
Apr 01, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove dial batching
parent
13d35565
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
44 deletions
+3
-44
swarm_dial.go
swarm_dial.go
+3
-44
No files found.
swarm_dial.go
View file @
4a69fa2f
...
@@ -480,37 +480,17 @@ loop:
...
@@ -480,37 +480,17 @@ loop:
}
}
case
<-
triggerDial
:
case
<-
triggerDial
:
// we dial batches of addresses together, logically belonging to the same batch
for
_
,
addr
:=
range
nextDial
{
// after a batch of addresses has been dialed, we add a delay before initiating the next batch
dialed
:=
false
last
:=
0
next
:=
0
for
i
,
addr
:=
range
nextDial
{
if
dialed
&&
!
s
.
sameAddrBatch
(
nextDial
[
last
],
addr
)
{
break
}
next
=
i
+
1
// spawn the dial
// spawn the dial
ad
:=
pending
[
addr
]
ad
:=
pending
[
addr
]
err
:=
s
.
dialNextAddr
(
ad
.
ctx
,
p
,
addr
,
resch
)
err
:=
s
.
dialNextAddr
(
ad
.
ctx
,
p
,
addr
,
resch
)
if
err
!=
nil
{
if
err
!=
nil
{
dispatchError
(
ad
,
err
)
dispatchError
(
ad
,
err
)
continue
}
}
ad
.
dialed
=
true
dialed
=
true
last
=
i
active
++
}
}
nextDial
=
nextDial
[
next
:
]
nextDial
=
nil
if
!
dialed
||
len
(
nextDial
)
==
0
{
// we didn't dial anything because of backoff or we don't have any more addresses
triggerDial
=
nil
triggerDial
=
nil
}
case
res
:=
<-
resch
:
case
res
:=
<-
resch
:
active
--
active
--
...
@@ -624,27 +604,6 @@ func (s *Swarm) dialNextAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr,
...
@@ -624,27 +604,6 @@ func (s *Swarm) dialNextAddr(ctx context.Context, p peer.ID, addr ma.Multiaddr,
return
nil
return
nil
}
}
func
(
s
*
Swarm
)
sameAddrBatch
(
a
,
b
ma
.
Multiaddr
)
bool
{
// is it a relay addr?
if
s
.
IsRelayAddr
(
a
)
{
return
s
.
IsRelayAddr
(
b
)
}
// is it an expensive addr?
if
s
.
IsExpensiveAddr
(
a
)
{
return
s
.
IsExpensiveAddr
(
b
)
}
// is it a public addr?
if
!
manet
.
IsPrivateAddr
(
a
)
{
return
!
manet
.
IsPrivateAddr
(
b
)
&&
s
.
IsFdConsumingAddr
(
a
)
==
s
.
IsFdConsumingAddr
(
b
)
}
// it's a private addr
return
manet
.
IsPrivateAddr
(
b
)
}
func
(
s
*
Swarm
)
canDial
(
addr
ma
.
Multiaddr
)
bool
{
func
(
s
*
Swarm
)
canDial
(
addr
ma
.
Multiaddr
)
bool
{
t
:=
s
.
TransportForDialing
(
addr
)
t
:=
s
.
TransportForDialing
(
addr
)
return
t
!=
nil
&&
t
.
CanDial
(
addr
)
return
t
!=
nil
&&
t
.
CanDial
(
addr
)
...
...
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