Skip to content

Commit

Permalink
Merge pull request #6276 from ipfs/feat/core-cfg-handling
Browse files Browse the repository at this point in the history
Invert constructor config handling
  • Loading branch information
Stebalien authored Apr 29, 2019
2 parents 92c88b0 + e133058 commit dd16b3c
Show file tree
Hide file tree
Showing 22 changed files with 946 additions and 773 deletions.
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

0 comments on commit dd16b3c

Please sign in to comment.