diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go index 27be53967dc8153be8ee8926ed6d69358f25952f..f849c1ed90df4e26117750eed964564c10b6e877 100644 --- a/exchange/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -202,6 +202,8 @@ func (bs *Bitswap) GetBlocks(ctx context.Context, keys []u.Key) (<-chan *blocks. } promise := bs.notifications.Subscribe(ctx, keys...) + bs.wm.WantBlocks(keys) + req := &blockRequest{ keys: keys, ctx: ctx, diff --git a/exchange/bitswap/workers.go b/exchange/bitswap/workers.go index 1083566a1fb10b6fb23b4eaca82e6fec3ee2edad..b41f0dd301670bd39c88e4bb151e3f6ce4a9a768 100644 --- a/exchange/bitswap/workers.go +++ b/exchange/bitswap/workers.go @@ -134,7 +134,7 @@ func (bs *Bitswap) provideCollector(ctx context.Context) { } } -// TODO ensure only one active request per key +// TODO: figure out clientWorkers purpose in life func (bs *Bitswap) clientWorker(parent context.Context) { defer log.Info("bitswap client worker shutting down...") @@ -147,8 +147,6 @@ func (bs *Bitswap) clientWorker(parent context.Context) { continue } - bs.wm.WantBlocks(keys) - // NB: Optimization. Assumes that providers of key[0] are likely to // be able to provide for all keys. This currently holds true in most // every situation. Later, this assumption may not hold as true. diff --git a/test/integration/bitswap_wo_routing_test.go b/test/integration/bitswap_wo_routing_test.go index f0f5d5d31e6c9d7ba9aaffc2b5c24f73451e4016..560e20ec3267bf04af8cbe6bbe1e0f4de69f613c 100644 --- a/test/integration/bitswap_wo_routing_test.go +++ b/test/integration/bitswap_wo_routing_test.go @@ -75,7 +75,7 @@ func TestBitswapWithoutRouting(t *testing.T) { } log.Debugf("%d %s get block.", i, n.Identity) - b, err := n.Exchange.GetBlock(ctx, block0.Key()) + b, err := n.Blocks.GetBlock(ctx, block0.Key()) if err != nil { t.Error(err) } else if !bytes.Equal(b.Data, block0.Data) { @@ -92,7 +92,7 @@ func TestBitswapWithoutRouting(t *testing.T) { // get it out. for _, n := range nodes { - b, err := n.Exchange.GetBlock(ctx, block1.Key()) + b, err := n.Blocks.GetBlock(ctx, block1.Key()) if err != nil { t.Error(err) } else if !bytes.Equal(b.Data, block1.Data) {