@@ -31,17 +31,16 @@ type bitswapOptionsOut struct {
31
31
BitswapOpts []bitswap.Option `group:"bitswap-options,flatten"`
32
32
}
33
33
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 {
38
37
var internalBsCfg config.InternalBitswap
39
38
if cfg .Internal .Bitswap != nil {
40
39
internalBsCfg = * cfg .Internal .Bitswap
41
40
}
42
41
43
42
opts := []bitswap.Option {
44
- bitswap .ProvideEnabled ( provide ),
43
+ bitswap .WithContentSearch ( routing ),
45
44
bitswap .ProviderSearchDelay (internalBsCfg .ProviderSearchDelay .WithDefault (DefaultProviderSearchDelay )), // See https://github.com/ipfs/go-ipfs/issues/8807 for rationale
46
45
bitswap .EngineBlockstoreWorkerCount (int (internalBsCfg .EngineBlockstoreWorkerCount .WithDefault (DefaultEngineBlockstoreWorkerCount ))),
47
46
bitswap .TaskWorkerCount (int (internalBsCfg .TaskWorkerCount .WithDefault (DefaultTaskWorkerCount ))),
@@ -50,25 +49,24 @@ func BitswapOptions(cfg *config.Config, provide bool) interface{} {
50
49
}
51
50
52
51
return bitswapOptionsOut {BitswapOpts : opts }
53
- }
52
+ })
54
53
}
55
54
56
55
type onlineExchangeIn struct {
57
56
fx.In
58
57
59
58
Mctx helpers.MetricsCtx
60
59
Host host.Host
61
- Rt irouting.ProvideManyRouter
62
60
Bs blockstore.GCBlockstore
63
61
BitswapOpts []bitswap.Option `group:"bitswap-options"`
64
62
}
65
63
66
64
// OnlineExchange creates new LibP2P backed block exchange (BitSwap).
67
65
// Additional options to bitswap.New can be provided via the "bitswap-options"
68
66
// 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 )
72
70
73
71
exch := bitswap .New (helpers .LifecycleCtx (in .Mctx , lc ), bitswapNetwork , in .Bs , in .BitswapOpts ... )
74
72
lc .Append (fx.Hook {
@@ -77,5 +75,5 @@ func OnlineExchange() interface{} {
77
75
},
78
76
})
79
77
return exch
80
- }
78
+ })
81
79
}
0 commit comments