dont panic on empty wantlist
Jeromy committed
Nov 18, 2014 at 21:46 UTC
5dece164cc23b325cc6576e5ff4a958c93b85018
1 file changed
+5
-1
exchange/bitswap/bitswap.go
+5
-1
@@ -163,9 +163,13 @@ func (bs *bitswap) run(ctx context.Context) {
163
for {
164
select {
165
case <-timeout:
166
+ wantlist := bs.wantlist.Keys()
167
+ if len(wantlist) == 0 {
168
+ continue
169
+ }
170
if sendlist == nil {
171
// rely on semi randomness of maps
168
- firstKey := bs.wantlist.Keys()[0]
172
+ firstKey := wantlist[0]
173
sendlist = bs.routing.FindProvidersAsync(ctx, firstKey, 6)
174
}
175
err := bs.sendWantListTo(ctx, sendlist)