Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

early out if no entries in wantlist #539

Merged
merged 1 commit into from
Jan 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion exchange/bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ func (bs *bitswap) sendWantlistToPeers(ctx context.Context, peers <-chan peer.ID
}

func (bs *bitswap) sendWantlistToProviders(ctx context.Context) {
entries := bs.wantlist.Entries()
if len(entries) == 0 {
log.Debug("No entries in wantlist, skipping send routine.")
return
}

log := log.Prefix("bitswap(%s).sendWantlistToProviders ", bs.self)
log.Debugf("begin")
defer log.Debugf("end")
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