mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 22:32:13 +00:00
fix: return a closed channel from FindProvidersAsync when providers are disabled.
This commit is contained in:
parent
c2b72b250d
commit
ba86f51884
@ -509,12 +509,13 @@ func (dht *IpfsDHT) FindProviders(ctx context.Context, c cid.Cid) ([]peer.AddrIn
|
|||||||
// Peers will be returned on the channel as soon as they are found, even before
|
// Peers will be returned on the channel as soon as they are found, even before
|
||||||
// the search query completes.
|
// the search query completes.
|
||||||
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo {
|
func (dht *IpfsDHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int) <-chan peer.AddrInfo {
|
||||||
|
peerOut := make(chan peer.AddrInfo, count)
|
||||||
if !dht.enableProviders {
|
if !dht.enableProviders {
|
||||||
return nil
|
close(peerOut)
|
||||||
|
return peerOut
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Event(ctx, "findProviders", key)
|
logger.Event(ctx, "findProviders", key)
|
||||||
peerOut := make(chan peer.AddrInfo, count)
|
|
||||||
|
|
||||||
go dht.findProvidersAsyncRoutine(ctx, key, count, peerOut)
|
go dht.findProvidersAsyncRoutine(ctx, key, count, peerOut)
|
||||||
return peerOut
|
return peerOut
|
||||||
|
Loading…
x
Reference in New Issue
Block a user