mirror of https://github.com/status-im/go-waku.git
fix: stop creating goroutines if context is already canceled (#1213)
This commit is contained in:
parent
69e1b559bc
commit
27d640e391
|
@ -144,6 +144,13 @@ func (m *MissingMessageVerifier) fetchHistory(c chan<- *protocol.Envelope, inter
|
|||
j = len(contentTopics)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-interest.ctx.Done():
|
||||
return
|
||||
default:
|
||||
// continue...
|
||||
}
|
||||
|
||||
now := m.timesource.Now()
|
||||
err := m.fetchMessagesBatch(c, interest, i, j, now)
|
||||
if err != nil {
|
||||
|
@ -260,6 +267,13 @@ func (m *MissingMessageVerifier) fetchMessagesBatch(c chan<- *protocol.Envelope,
|
|||
j = len(missingHashes)
|
||||
}
|
||||
|
||||
select {
|
||||
case <-interest.ctx.Done():
|
||||
return nil
|
||||
default:
|
||||
// continue...
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
go func(messageHashes []pb.MessageHash) {
|
||||
defer wg.Wait()
|
||||
|
|
Loading…
Reference in New Issue