@@ -31,17 +31,16 @@ type bitswapOptionsOut struct {
3131 BitswapOpts []bitswap.Option `group:"bitswap-options,flatten"`
3232}
3333
34- // BitswapOptions creates configuration options for Bitswap from the config file
35- // and whether to provide data.
36- func BitswapOptions (cfg * config.Config , provide bool ) interface {} {
37- return func () bitswapOptionsOut {
34+ // BitswapOptions creates configuration options for Bitswap from the config file.
35+ func BitswapOptions (cfg * config.Config ) fx.Option {
36+ return fx .Provide (func (routing irouting.ProvideManyRouter ) bitswapOptionsOut {
3837 var internalBsCfg config.InternalBitswap
3938 if cfg .Internal .Bitswap != nil {
4039 internalBsCfg = * cfg .Internal .Bitswap
4140 }
4241
4342 opts := []bitswap.Option {
44- bitswap .ProvideEnabled ( provide ),
43+ bitswap .WithContentSearch ( routing ),
4544 bitswap .ProviderSearchDelay (internalBsCfg .ProviderSearchDelay .WithDefault (DefaultProviderSearchDelay )), // See https://github.com/ipfs/go-ipfs/issues/8807 for rationale
4645 bitswap .EngineBlockstoreWorkerCount (int (internalBsCfg .EngineBlockstoreWorkerCount .WithDefault (DefaultEngineBlockstoreWorkerCount ))),
4746 bitswap .TaskWorkerCount (int (internalBsCfg .TaskWorkerCount .WithDefault (DefaultTaskWorkerCount ))),
@@ -50,25 +49,24 @@ func BitswapOptions(cfg *config.Config, provide bool) interface{} {
5049 }
5150
5251 return bitswapOptionsOut {BitswapOpts : opts }
53- }
52+ })
5453}
5554
5655type onlineExchangeIn struct {
5756 fx.In
5857
5958 Mctx helpers.MetricsCtx
6059 Host host.Host
61- Rt irouting.ProvideManyRouter
6260 Bs blockstore.GCBlockstore
6361 BitswapOpts []bitswap.Option `group:"bitswap-options"`
6462}
6563
6664// OnlineExchange creates new LibP2P backed block exchange (BitSwap).
6765// Additional options to bitswap.New can be provided via the "bitswap-options"
6866// group.
69- func OnlineExchange () interface {} {
70- return func (in onlineExchangeIn , lc fx.Lifecycle ) exchange.Interface {
71- bitswapNetwork := network .NewFromIpfsHost (in .Host , in . Rt )
67+ func OnlineExchange () fx. Option {
68+ return fx . Provide ( func (in onlineExchangeIn , lc fx.Lifecycle ) exchange.Interface {
69+ bitswapNetwork := network .NewFromIpfsHost (in .Host )
7270
7371 exch := bitswap .New (helpers .LifecycleCtx (in .Mctx , lc ), bitswapNetwork , in .Bs , in .BitswapOpts ... )
7472 lc .Append (fx.Hook {
@@ -77,5 +75,5 @@ func OnlineExchange() interface{} {
7775 },
7876 })
7977 return exch
80- }
78+ })
8179}
0 commit comments