1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-26 07:28:20 +08:00

early out if no entries in wantlist

This commit is contained in:
Jeromy
2015-01-11 08:03:46 +00:00
parent 456719ede7
commit a09854db97

View File

@ -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")
@ -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()