mirror of https://github.com/status-im/go-waku.git
fix: invalid ticker usage
This commit is contained in:
parent
78a0d4d74d
commit
e8c08ac18b
|
@ -426,14 +426,16 @@ func (w *WakuNode) startStore() {
|
|||
// TODO: extract this to a function and run it when you go offline
|
||||
// TODO: determine if a store is listening to a topic
|
||||
go func() {
|
||||
ticker := time.NewTicker(time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
t := time.NewTicker(time.Second)
|
||||
peerVerif:
|
||||
for {
|
||||
select {
|
||||
case <-w.quit:
|
||||
return
|
||||
case <-t.C:
|
||||
case <-ticker.C:
|
||||
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta3))
|
||||
if err == nil {
|
||||
break peerVerif
|
||||
|
@ -578,6 +580,7 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
|||
log.Info("Setting up ping protocol with duration of ", t)
|
||||
|
||||
ticker := time.NewTicker(t)
|
||||
defer ticker.Stop()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
|
@ -595,7 +598,6 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
|||
}
|
||||
}
|
||||
case <-w.quit:
|
||||
ticker.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,12 +74,15 @@ func (self *MessageQueue) cleanOlderRecords() {
|
|||
|
||||
func (self *MessageQueue) checkForOlderRecords(d time.Duration) {
|
||||
ticker := time.NewTicker(d)
|
||||
defer ticker.Stop()
|
||||
|
||||
select {
|
||||
case <-self.quit:
|
||||
return
|
||||
case <-ticker.C:
|
||||
self.cleanOlderRecords()
|
||||
for {
|
||||
select {
|
||||
case <-self.quit:
|
||||
return
|
||||
case <-ticker.C:
|
||||
self.cleanOlderRecords()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue