Commit b62e6559 authored by Brian Tiger Chow's avatar Brian Tiger Chow

feat(exchange) pass ctx to exchange.HasBlock(...)

parent 55b425a8
......@@ -128,8 +128,7 @@ func (bs *bitswap) sendToPeersThatWant(ctx context.Context, block blocks.Block)
// HasBlock announces the existance of a block to bitswap, potentially sending
// it to peers (Partners) whose WantLists include it.
func (bs *bitswap) HasBlock(blk blocks.Block) error {
ctx := context.TODO()
func (bs *bitswap) HasBlock(ctx context.Context, blk blocks.Block) error {
go bs.sendToPeersThatWant(ctx, blk)
return bs.routing.Provide(blk.Key())
}
......
......@@ -27,6 +27,6 @@ func (_ *offlineExchange) Block(context.Context, u.Key) (*blocks.Block, error) {
}
// HasBlock always returns nil.
func (_ *offlineExchange) HasBlock(blocks.Block) error {
func (_ *offlineExchange) HasBlock(context.Context, blocks.Block) error {
return nil
}
......@@ -11,7 +11,7 @@ import (
func TestBlockReturnsErr(t *testing.T) {
off := NewOfflineExchange()
_, err := off.Block(context.TODO(), u.Key("foo"))
_, err := off.Block(context.Background(), u.Key("foo"))
if err != nil {
return // as desired
}
......@@ -21,7 +21,7 @@ func TestBlockReturnsErr(t *testing.T) {
func TestHasBlockReturnsNil(t *testing.T) {
off := NewOfflineExchange()
block := testutil.NewBlockOrFail(t, "data")
err := off.HasBlock(block)
err := off.HasBlock(context.Background(), block)
if err != nil {
t.Fatal("")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment