Skip to content

Commit

Permalink
early out if no entries in wantlist
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Jan 11, 2015
1 parent 456719e commit 1c7b427
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion exchange/bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context) {
log.Debugf("begin")
defer log.Debugf("end")

entries := bs.wantlist.Entries()
if len(entries) == 0 {
log.Debug("No entries in wantlist, skipping send routine.")
return
}

ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand All @@ -237,7 +243,7 @@ func (bs *bitswap) sendWantlistToProviders(ctx context.Context) {

// Get providers for all entries in wantlist (could take a while)
wg := sync.WaitGroup{}
for _, e := range bs.wantlist.Entries() {
for _, e := range entries {
wg.Add(1)
go func(k u.Key) {
defer wg.Done()
Expand Down

0 comments on commit 1c7b427

Please sign in to comment.