Commit 1b7c0b14 authored by Jeromy's avatar Jeromy

remove unnecessary concurrency in last commit

parent 90f5ec0c
......@@ -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
......
......@@ -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")
......
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