提交 7c00bcf3 作者: Jeromy Johnson 提交者: GitHub

Merge pull request #3192 from ipfs/fix/bitswap/too-many-findprovs

bitswap: search for wantlist providers a little less often
package bitswap package bitswap
import ( import (
"math/rand"
"sync" "sync"
"time" "time"
...@@ -175,15 +176,14 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) { ...@@ -175,15 +176,14 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) {
if len(entries) == 0 { if len(entries) == 0 {
continue continue
} }
tctx, cancel := context.WithTimeout(ctx, providerRequestTimeout)
for _, e := range bs.wm.wl.Entries() { // TODO: come up with a better strategy for determining when to search
e := e // for new providers for blocks.
bs.findKeys <- &blockRequest{ i := rand.Intn(len(entries))
Key: e.Key, bs.findKeys <- &blockRequest{
Ctx: tctx, Key: entries[i].Key,
} Ctx: ctx,
} }
cancel()
case <-parent.Done(): case <-parent.Done():
return return
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论