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
7ccf58e5
Commit
7ccf58e5
authored
Mar 31, 2021
by
vyzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use a timer instead of time.After
parent
a6c28389
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
1 deletion
+16
-1
swarm_dial.go
swarm_dial.go
+16
-1
No files found.
swarm_dial.go
View file @
7ccf58e5
...
...
@@ -361,9 +361,16 @@ 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
)
close
(
triggerNow
)
defer
func
()
{
if
triggerTimer
!=
nil
{
triggerTimer
.
Stop
()
}
}()
var
nextDial
[]
ma
.
Multiaddr
active
:=
0
done
:=
false
...
...
@@ -504,7 +511,15 @@ loop:
// select an appropriate delay for the next dial batch
delay
:=
s
.
delayForNextDial
(
lastDial
)
triggerDial
=
time
.
After
(
delay
)
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
--
...
...
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