bitswap: search for wantlist providers a little less often
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Sep 5, 2016 at 20:13 UTC
803af90180e207261a2ca603737be8954b5e3ef8
1 file changed
+8
-8
exchange/bitswap/workers.go
+8
-8
@@ -1,6 +1,7 @@
1
package bitswap
2
3
import (
4
+ "math/rand"
5
"sync"
6
"time"
7
@@ -175,15 +176,14 @@ func (bs *Bitswap) rebroadcastWorker(parent context.Context) {
176
if len(entries) == 0 {
177
continue
178
}
178
- tctx, cancel := context.WithTimeout(ctx, providerRequestTimeout)
179
- for _, e := range bs.wm.wl.Entries() {
180
- e := e
181
- bs.findKeys <- &blockRequest{
182
- Key: e.Key,
183
- Ctx: tctx,
184
- }
179
+
180
+ // TODO: come up with a better strategy for determining when to search
181
+ // for new providers for blocks.
182
+ i := rand.Intn(len(entries))
183
+ bs.findKeys <- &blockRequest{
184
+ Key: entries[i].Key,
185
+ Ctx: ctx,
186
}
186
- cancel()
187
case <-parent.Done():
188
return
189
}