Skip to content

Commit df4d510

Browse files
committed
fixed two more
1 parent bf64daf commit df4d510

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

exchange/bitswap/workers.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,12 @@ func (bs *Bitswap) provideWorker(ctx context.Context) {
6868
log.Debug("provideKeys channel closed")
6969
return
7070
}
71-
ctx, _ := context.WithTimeout(ctx, provideTimeout)
71+
ctx, cancel := context.WithTimeout(ctx, provideTimeout)
7272
err := bs.network.Provide(ctx, k)
7373
if err != nil {
7474
log.Error(err)
7575
}
76+
cancel()
7677
case <-ctx.Done():
7778
return
7879
}
@@ -136,12 +137,13 @@ func (bs *Bitswap) clientWorker(parent context.Context) {
136137
// NB: Optimization. Assumes that providers of key[0] are likely to
137138
// be able to provide for all keys. This currently holds true in most
138139
// every situation. Later, this assumption may not hold as true.
139-
child, _ := context.WithTimeout(req.ctx, providerRequestTimeout)
140+
child, cancel := context.WithTimeout(req.ctx, providerRequestTimeout)
140141
providers := bs.network.FindProvidersAsync(child, keys[0], maxProvidersPerRequest)
141142
err := bs.sendWantlistToPeers(req.ctx, providers)
142143
if err != nil {
143144
log.Debugf("error sending wantlist: %s", err)
144145
}
146+
cancel()
145147

146148
// Wait for wantNewBlocks to finish
147149
<-done

0 commit comments

Comments
 (0)