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: extract this to a function and run it when you go offline
|
||||||
// TODO: determine if a store is listening to a topic
|
// TODO: determine if a store is listening to a topic
|
||||||
go func() {
|
go func() {
|
||||||
|
ticker := time.NewTicker(time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
t := time.NewTicker(time.Second)
|
|
||||||
peerVerif:
|
peerVerif:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-w.quit:
|
case <-w.quit:
|
||||||
return
|
return
|
||||||
case <-t.C:
|
case <-ticker.C:
|
||||||
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta3))
|
_, err := utils.SelectPeer(w.host, string(store.StoreID_v20beta3))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break peerVerif
|
break peerVerif
|
||||||
|
@ -578,6 +580,7 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
||||||
log.Info("Setting up ping protocol with duration of ", t)
|
log.Info("Setting up ping protocol with duration of ", t)
|
||||||
|
|
||||||
ticker := time.NewTicker(t)
|
ticker := time.NewTicker(t)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
|
@ -595,7 +598,6 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case <-w.quit:
|
case <-w.quit:
|
||||||
ticker.Stop()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,9 @@ func (self *MessageQueue) cleanOlderRecords() {
|
||||||
|
|
||||||
func (self *MessageQueue) checkForOlderRecords(d time.Duration) {
|
func (self *MessageQueue) checkForOlderRecords(d time.Duration) {
|
||||||
ticker := time.NewTicker(d)
|
ticker := time.NewTicker(d)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
select {
|
select {
|
||||||
case <-self.quit:
|
case <-self.quit:
|
||||||
return
|
return
|
||||||
|
@ -82,6 +84,7 @@ func (self *MessageQueue) checkForOlderRecords(d time.Duration) {
|
||||||
self.cleanOlderRecords()
|
self.cleanOlderRecords()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *MessageQueue) Length() int {
|
func (self *MessageQueue) Length() int {
|
||||||
self.RLock()
|
self.RLock()
|
||||||
|
|
Loading…
Reference in New Issue