mirror of
https://github.com/status-im/go-waku.git
synced 2025-01-27 05:56:07 +00:00
fix: do not block ctx.Done() on peer discovery
This commit is contained in:
parent
e14c55c263
commit
fa61e58d3b
@ -294,8 +294,13 @@ func (d *DiscoveryV5) iterate(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if len(peerAddrs) != 0 {
|
||||
d.peerConnector.PeerChannel() <- peerAddrs[0]
|
||||
select {
|
||||
case d.peerConnector.PeerChannel() <- peerAddrs[0]:
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
|
@ -124,7 +124,11 @@ func (r *Rendezvous) discover(ctx context.Context) {
|
||||
server.Unlock()
|
||||
|
||||
for _, addr := range addrInfo {
|
||||
r.peerConnector.PeerChannel() <- addr
|
||||
select {
|
||||
case r.peerConnector.PeerChannel() <- addr:
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: change log level to DEBUG in go-libp2p-rendezvous@v0.4.1/svc.go:234 discover query
|
||||
|
Loading…
x
Reference in New Issue
Block a user