mirror of
https://github.com/FlipsideCrypto/dcrd.git
synced 2026-02-06 10:56:47 +00:00
dcrd: Do not send a wakeup if not sleeping (#314)
A simple printf shows dozens of AfterFuncs being generated, especially on testnet where the connectable node count is currently low. By resetting the timer, it prevents needless wakeups from filling the channel.
This commit is contained in:
parent
145065c87f
commit
3c9995dd4a
@ -1827,7 +1827,8 @@ func (s *server) peerHandler() {
|
||||
}
|
||||
|
||||
// if nothing else happens, wake us up soon.
|
||||
time.AfterFunc(10*time.Second, func() { s.wakeup <- struct{}{} })
|
||||
wakeupAfter := 10 * time.Second
|
||||
timer := time.AfterFunc(wakeupAfter, func() { s.wakeup <- struct{}{} })
|
||||
|
||||
out:
|
||||
for {
|
||||
@ -1946,9 +1947,7 @@ out:
|
||||
|
||||
// We need more peers, wake up in ten seconds and try again.
|
||||
if state.NeedMoreOutbound() {
|
||||
time.AfterFunc(10*time.Second, func() {
|
||||
s.wakeup <- struct{}{}
|
||||
})
|
||||
timer.Reset(wakeupAfter)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user