Skip to content

Commit

Permalink
Bitswap Getblocks: CancelWant on ctx cancel
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: rht <[email protected]>
  • Loading branch information
rht committed Nov 22, 2015
1 parent b4ab684 commit 5717463
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions exchange/bitswap/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ func (bs *Bitswap) GetBlocks(ctx context.Context, keys []key.Key) (<-chan *block
log.Event(ctx, "Bitswap.GetBlockRequest.Start", &k)
}

go func() {
select {
case <-ctx.Done():
bs.CancelWants(keys)
}
}()
bs.wm.WantBlocks(keys)

req := &blockRequest{
Expand Down

0 comments on commit 5717463

Please sign in to comment.