diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go index ac9224228bbf396927fdbbe4fd42248727d52678..e00b23f9193926a6fa4eb120c8ea9fe1172caf5d 100644 --- a/exchange/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -253,20 +253,10 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error { bs.wantlist.Remove(blk.Key()) bs.notifications.Publish(blk) - var err error - wg := &sync.WaitGroup{} - wg.Add(2) child, _ := context.WithTimeout(ctx, hasBlockTimeout) - go func() { - bs.sendToPeersThatWant(child, blk) - wg.Done() - }() - go func() { - err = bs.routing.Provide(child, blk.Key()) - wg.Done() - }() - wg.Wait() - return err + bs.sendToPeersThatWant(child, blk) + child, _ = context.WithTimeout(ctx, hasBlockTimeout) + return bs.routing.Provide(child, blk.Key()) } // receiveBlock handles storing the block in the blockstore and calling HasBlock diff --git a/exchange/bitswap/bitswap_test.go b/exchange/bitswap/bitswap_test.go index ede87c47477ba3f22ea32442115c48e1d712f05b..d26a8ffc9cf70f6aa9dad87b8dd068c280f18433 100644 --- a/exchange/bitswap/bitswap_test.go +++ b/exchange/bitswap/bitswap_test.go @@ -235,7 +235,7 @@ func TestSendToWantingPeer(t *testing.T) { t.Logf("%v should now have %v\n", w.Peer, alpha.Key()) block, err := w.Blockstore.Get(alpha.Key()) if err != nil { - t.Fatal("Should not have received an error") + t.Fatalf("Should not have received an error: %s", err) } if block.Key() != alpha.Key() { t.Fatal("Expected to receive alpha from me")