Ensure that discovery producer is stopped
This commit is contained in:
parent
6a1cd7f2b0
commit
ff7c0e0a17
|
@ -192,8 +192,18 @@ func (r *Rendezvous) Discover(
|
|||
log.Debug("converted enr to", "ENODE", n.String())
|
||||
if err != nil {
|
||||
log.Warn("error converting enr record to node", "err", err)
|
||||
continue
|
||||
}
|
||||
select {
|
||||
case found <- n:
|
||||
case newPeriod, ok := <-period:
|
||||
// closing a period channel is a signal to producer that consumer exited
|
||||
ticker.Stop()
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
ticker = time.NewTicker(newPeriod)
|
||||
}
|
||||
found <- n
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,12 +201,12 @@ func (p *PeerPool) stopDiscovery(server *p2p.Server) {
|
|||
return
|
||||
}
|
||||
|
||||
if err := p.discovery.Stop(); err != nil {
|
||||
log.Error("discovery errored when stopping", "err", err)
|
||||
}
|
||||
for _, t := range p.topics {
|
||||
t.StopSearch(server)
|
||||
}
|
||||
if err := p.discovery.Stop(); err != nil {
|
||||
log.Error("discovery errored when was closed", "err", err)
|
||||
}
|
||||
|
||||
p.mu.Lock()
|
||||
p.timeout = nil
|
||||
|
|
Loading…
Reference in New Issue