@cryptotaxi247 / kubo / commits / a09854db9

early out if no entries in wantlist

Jeromy committed Jan 11, 2015 at 08:03 UTC a09854db97c099664a61a077910486199b10f92b
1 file changed +7 -1
exchange/bitswap/bitswap.go
+7 -1
@@ -225,6 +225,12 @@ func (bs *bitswap) sendWantlistToPeers(ctx context.Context, peers <-chan peer.ID
225 }
226
227 func (bs *bitswap) sendWantlistToProviders(ctx context.Context) {
228 + entries := bs.wantlist.Entries()
229 + if len(entries) == 0 {
230 + log.Debug("No entries in wantlist, skipping send routine.")
231 + return
232 + }
233 +
234 log := log.Prefix("bitswap(%s).sendWantlistToProviders ", bs.self)
235 log.Debugf("begin")
236 defer log.Debugf("end")
@@ -237,7 +243,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context) {
243
244 // Get providers for all entries in wantlist (could take a while)
245 wg := sync.WaitGroup{}
240 - for _, e := range bs.wantlist.Entries() {
246 + for _, e := range entries {
247 wg.Add(1)
248 go func(k u.Key) {
249 defer wg.Done()