Skip to content

Commit ca09167

Browse files
committed
fix bug in count=0 findProviders
1 parent a366d8b commit ca09167

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dual/dual.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,14 @@ func (dht *DHT) FindProvidersAsync(ctx context.Context, key cid.Cid, count int)
9595
outCh := make(chan peer.AddrInfo)
9696
wanCh := dht.WAN.FindProvidersAsync(reqCtx, key, count)
9797
lanCh := dht.LAN.FindProvidersAsync(reqCtx, key, count)
98+
zeroCount := (count == 0)
9899
go func() {
99100
defer cancel()
100101
defer close(outCh)
101102

102103
found := make(map[peer.ID]struct{}, count)
103104
var pi peer.AddrInfo
104-
for count > 0 && (wanCh != nil || lanCh != nil) {
105+
for (zeroCount || count > 0) && (wanCh != nil || lanCh != nil) {
105106
var ok bool
106107
select {
107108
case pi, ok = <-wanCh:

0 commit comments

Comments
 (0)