refactor: avoid loop reuse
License: MIT Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
Brian Tiger Chow committed
Dec 16, 2014 at 20:31 UTC
8c05c444a5ad758b3a6e1bfec1767221f17b9340
1 file changed
+4
-2
exchange/bitswap/bitswap.go
+4
-2
@@ -309,14 +309,16 @@ func (bs *bitswap) ReceiveMessage(ctx context.Context, p peer.Peer, incoming bsm
309
// TODO: this is bad, and could be easily abused.
310
// Should only track *useful* messages in ledger
311
312
- var blkeys []u.Key
312
for _, block := range incoming.Blocks() {
314
- blkeys = append(blkeys, block.Key())
313
hasBlockCtx, _ := context.WithTimeout(ctx, hasBlockTimeout)
314
if err := bs.HasBlock(hasBlockCtx, block); err != nil {
315
log.Error(err)
316
}
317
}
318
+ var blkeys []u.Key
319
+ for _, block := range incoming.Blocks() {
320
+ blkeys = append(blkeys, block.Key())
321
+ }
322
if len(blkeys) > 0 {
323
bs.cancelBlocks(ctx, blkeys)
324
}