Browse Source
replace repeate timer with simple ticker
no need for repeate timer here (no need for goroutine safety)
pull/456/head
Anton Kalyaev
8 years ago
committed by
Anton Kaliaev
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with
3 additions and
4 deletions
-
pex_reactor.go
|
|
@ -142,19 +142,18 @@ func (r *PEXReactor) ensurePeersRoutine() { |
|
|
|
r.ensurePeers() |
|
|
|
|
|
|
|
// fire periodically
|
|
|
|
timer := NewRepeatTimer("pex", r.ensurePeersPeriod) |
|
|
|
ticker := time.NewTicker(r.ensurePeersPeriod) |
|
|
|
FOR_LOOP: |
|
|
|
for { |
|
|
|
select { |
|
|
|
case <-timer.Ch: |
|
|
|
case <-ticker.C: |
|
|
|
r.ensurePeers() |
|
|
|
case <-r.Quit: |
|
|
|
break FOR_LOOP |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
timer.Stop() |
|
|
|
ticker.Stop() |
|
|
|
} |
|
|
|
|
|
|
|
// ensurePeers ensures that sufficient peers are connected. (once)
|
|
|
|