@cryptotaxi247 / kubo / commits / 432eee651

remove unnecessary concurrency in last commit

Jeromy committed Dec 2, 2014 at 08:03 UTC 432eee651fc82ff5e9161254410662542e8e1659
2 files changed +4 -14
exchange/bitswap/bitswap.go
+3 -13
@@ -253,20 +253,10 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
253 bs.wantlist.Remove(blk.Key())
254 bs.notifications.Publish(blk)
255
256 - var err error
257 - wg := &sync.WaitGroup{}
258 - wg.Add(2)
256 child, _ := context.WithTimeout(ctx, hasBlockTimeout)
260 - go func() {
261 - bs.sendToPeersThatWant(child, blk)
262 - wg.Done()
263 - }()
264 - go func() {
265 - err = bs.routing.Provide(child, blk.Key())
266 - wg.Done()
267 - }()
268 - wg.Wait()
269 - return err
257 + bs.sendToPeersThatWant(child, blk)
258 + child, _ = context.WithTimeout(ctx, hasBlockTimeout)
259 + return bs.routing.Provide(child, blk.Key())
260 }
261
262 // receiveBlock handles storing the block in the blockstore and calling HasBlock
exchange/bitswap/bitswap_test.go
+1 -1
@@ -235,7 +235,7 @@ func TestSendToWantingPeer(t *testing.T) {
235 t.Logf("%v should now have %v\n", w.Peer, alpha.Key())
236 block, err := w.Blockstore.Get(alpha.Key())
237 if err != nil {
238 - t.Fatal("Should not have received an error")
238 + t.Fatalf("Should not have received an error: %s", err)
239 }
240 if block.Key() != alpha.Key() {
241 t.Fatal("Expected to receive alpha from me")