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
0fc0ade2
Commit
0fc0ade2
authored
Mar 31, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kill dial jump delays
parent
7ccf58e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
41 deletions
+2
-41
swarm_dial.go
swarm_dial.go
+2
-41
No files found.
swarm_dial.go
View file @
0fc0ade2
...
...
@@ -57,12 +57,6 @@ var (
ErrGaterDisallowedConnection
=
errors
.
New
(
"gater disallows connection to peer"
)
)
var
(
delayDialPrivateAddr
=
1
*
time
.
Millisecond
delayDialPublicAddr
=
5
*
time
.
Millisecond
delayDialRelayAddr
=
10
*
time
.
Millisecond
)
// DialAttempts governs how many times a goroutine will try to dial a given peer.
// Note: this is down to one, as we have _too many dials_ atm. To add back in,
// add loop back in Dial(.)
...
...
@@ -360,17 +354,10 @@ func (s *Swarm) dialWorkerLoop(ctx context.Context, p peer.ID, reqch <-chan Dial
}
}
var
triggerDial
<-
chan
time
.
Time
var
triggerTimer
*
time
.
Timer
triggerNow
:=
make
(
chan
time
.
Time
)
var
triggerDial
<-
chan
struct
{}
triggerNow
:=
make
(
chan
struct
{})
close
(
triggerNow
)
defer
func
()
{
if
triggerTimer
!=
nil
{
triggerTimer
.
Stop
()
}
}()
var
nextDial
[]
ma
.
Multiaddr
active
:=
0
done
:=
false
...
...
@@ -501,26 +488,12 @@ loop:
active
++
}
lastDial
:=
nextDial
[
last
]
nextDial
=
nextDial
[
next
:
]
if
!
dialed
||
len
(
nextDial
)
==
0
{
// we didn't dial anything because of backoff or we don't have any more addresses
triggerDial
=
nil
continue
loop
}
// select an appropriate delay for the next dial batch
delay
:=
s
.
delayForNextDial
(
lastDial
)
if
triggerTimer
==
nil
{
triggerTimer
=
time
.
NewTimer
(
delay
)
}
else
{
if
!
triggerTimer
.
Stop
()
&&
triggerDial
!=
triggerTimer
.
C
{
<-
triggerTimer
.
C
}
triggerTimer
.
Reset
(
delay
)
}
triggerDial
=
triggerTimer
.
C
case
res
:=
<-
resch
:
active
--
...
...
@@ -636,18 +609,6 @@ func (s *Swarm) sameAddrBatch(a, b ma.Multiaddr) bool {
return
manet
.
IsPrivateAddr
(
b
)
}
func
(
s
*
Swarm
)
delayForNextDial
(
addr
ma
.
Multiaddr
)
time
.
Duration
{
if
_
,
err
:=
addr
.
ValueForProtocol
(
ma
.
P_CIRCUIT
);
err
==
nil
{
return
delayDialRelayAddr
}
if
manet
.
IsPrivateAddr
(
addr
)
{
return
delayDialPrivateAddr
}
return
delayDialPublicAddr
}
func
(
s
*
Swarm
)
canDial
(
addr
ma
.
Multiaddr
)
bool
{
t
:=
s
.
TransportForDialing
(
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