Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert constructor config handling #6276

Merged
merged 4 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ type IpfsNode struct {
// Local node
Pinning pin.Pinner // the pinning manager
Mounts Mounts `optional:"true"` // current mount state, if any.
PrivateKey ic.PrivKey // the local node's private Key
PrivateKey ic.PrivKey `optional:"true"` // the local node's private Key
PNetFingerprint libp2p.PNetFingerprint `optional:"true"` // fingerprint of private network

// Services
Peerstore pstore.Peerstore `optional:"true"` // storage for other Peer instances
Blockstore bstore.GCBlockstore // the block store (lower level)
Filestore *filestore.Filestore // the filestore blockstore
Filestore *filestore.Filestore `optional:"true"` // the filestore blockstore
BaseBlocks node.BaseBlocks // the raw blockstore, no filestore wrapping
GCLocker bstore.GCLocker // the locker used to protect the blockstore during gc
Blocks bserv.BlockService // the block service, get/add blocks.
Expand Down
11 changes: 8 additions & 3 deletions core/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ func (cfg *BuildCfg) fillDefaults() error {
}

// options creates fx option group from this build config
func (cfg *BuildCfg) options(ctx context.Context) fx.Option {
func (cfg *BuildCfg) options(ctx context.Context) (fx.Option, *cfg.Config) {
err := cfg.fillDefaults()
if err != nil {
return fx.Error(err)
return fx.Error(err), nil
}

repoOption := fx.Provide(func(lc fx.Lifecycle) repo.Repo {
Expand All @@ -112,12 +112,17 @@ func (cfg *BuildCfg) options(ctx context.Context) fx.Option {
return cfg.Routing
})

conf, err := cfg.Repo.Config()
if err != nil {
return fx.Error(err), nil
}

return fx.Options(
repoOption,
hostOption,
routingOption,
metricsCtx,
)
), conf
}

func defaultRepo(dstore repo.Datastore) (repo.Repo, error) {
Expand Down
Loading