Commit 709075f7 authored by Jeromy's avatar Jeromy

dont panic on empty wantlist

parent fefe7d37
...@@ -163,9 +163,13 @@ func (bs *bitswap) run(ctx context.Context) { ...@@ -163,9 +163,13 @@ func (bs *bitswap) run(ctx context.Context) {
for { for {
select { select {
case <-timeout: case <-timeout:
wantlist := bs.wantlist.Keys()
if len(wantlist) == 0 {
continue
}
if sendlist == nil { if sendlist == nil {
// rely on semi randomness of maps // rely on semi randomness of maps
firstKey := bs.wantlist.Keys()[0] firstKey := wantlist[0]
sendlist = bs.routing.FindProvidersAsync(ctx, firstKey, 6) sendlist = bs.routing.FindProvidersAsync(ctx, firstKey, 6)
} }
err := bs.sendWantListTo(ctx, sendlist) err := bs.sendWantListTo(ctx, sendlist)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment