From 432eee651fc82ff5e9161254410662542e8e1659 Mon Sep 17 00:00:00 2001
From: Jeromy <jeromyj@gmail.com>
Date: Tue, 2 Dec 2014 08:03:00 +0000
Subject: [PATCH] remove unnecessary concurrency in last commit

---
 exchange/bitswap/bitswap.go      | 16 +++-------------
 exchange/bitswap/bitswap_test.go |  2 +-
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go
index ac9224228..e00b23f91 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 ede87c474..d26a8ffc9 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")
-- 
GitLab