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 { ...@@ -253,20 +253,10 @@ func (bs *bitswap) HasBlock(ctx context.Context, blk *blocks.Block) error {
bs.wantlist.Remove(blk.Key()) bs.wantlist.Remove(blk.Key())
bs.notifications.Publish(blk) bs.notifications.Publish(blk)
var err error
wg := &sync.WaitGroup{}
wg.Add(2)
child, _ := context.WithTimeout(ctx, hasBlockTimeout) child, _ := context.WithTimeout(ctx, hasBlockTimeout)
go func() { bs.sendToPeersThatWant(child, blk)
bs.sendToPeersThatWant(child, blk) child, _ = context.WithTimeout(ctx, hasBlockTimeout)
wg.Done() return bs.routing.Provide(child, blk.Key())
}()
go func() {
err = bs.routing.Provide(child, blk.Key())
wg.Done()
}()
wg.Wait()
return err
} }
// receiveBlock handles storing the block in the blockstore and calling HasBlock // receiveBlock handles storing the block in the blockstore and calling HasBlock
......
...@@ -235,7 +235,7 @@ func TestSendToWantingPeer(t *testing.T) { ...@@ -235,7 +235,7 @@ func TestSendToWantingPeer(t *testing.T) {
t.Logf("%v should now have %v\n", w.Peer, alpha.Key()) t.Logf("%v should now have %v\n", w.Peer, alpha.Key())
block, err := w.Blockstore.Get(alpha.Key()) block, err := w.Blockstore.Get(alpha.Key())
if err != nil { 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() { if block.Key() != alpha.Key() {
t.Fatal("Expected to receive alpha from me") 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