Skip to content

Commit

Permalink
Move cfg out to groups
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavila committed May 6, 2019
1 parent 54860eb commit 77259cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions core/node/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"

"github.com/ipfs/go-ipfs-config"
"github.com/ipfs/go-ipfs/core/node/helpers"
"github.com/ipfs/go-ipfs/pin"
"github.com/ipfs/go-ipfs/repo"
Expand Down Expand Up @@ -60,16 +59,19 @@ func Dag(bs blockservice.BlockService) format.DAGService {
}

// OnlineExchange creates new LibP2P backed block exchange (BitSwap)
func OnlineExchange(mctx helpers.MetricsCtx, lc fx.Lifecycle, cfg *config.Config, host host.Host, rt routing.IpfsRouting, bs blockstore.GCBlockstore) exchange.Interface {
bitswapNetwork := network.NewFromIpfsHost(host, rt)
bitswap.ProvideEnabled = !cfg.Experimental.StrategicProviding
exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, bs)
lc.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
return exch.Close()
},
})
return exch
func OnlineExchange(provide bool) interface{} {
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt routing.IpfsRouting, bs blockstore.GCBlockstore) exchange.Interface {
bitswapNetwork := network.NewFromIpfsHost(host, rt)
bitswap.ProvideEnabled = provide
exch := bitswap.New(helpers.LifecycleCtx(mctx, lc), bitswapNetwork, bs)
lc.Append(fx.Hook{
OnStop: func(ctx context.Context) error {
return exch.Close()
},
})
return exch

}
}

// Files loads persisted MFS root
Expand Down
2 changes: 1 addition & 1 deletion core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option {
}

return fx.Options(
fx.Provide(OnlineExchange),
fx.Provide(OnlineExchange(!cfg.Experimental.StrategicProviding)),
fx.Provide(Namesys(ipnsCacheSize)),

fx.Invoke(IpnsRepublisher(repubPeriod, recordLifetime)),
Expand Down

2 comments on commit 77259cd

@GitCop
Copy link

@GitCop GitCop commented on 77259cd May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

@GitCop GitCop commented on 77259cd May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.