diff --git a/node/builder.go b/node/builder.go index dfc6eab29..47e685543 100644 --- a/node/builder.go +++ b/node/builder.go @@ -586,16 +586,16 @@ func Repo(r repo.Repo) Option { return err } - var cfg *config.Blockstore + var cfg *config.Chainstore switch settings.nodeType { case repo.FullNode: cfgp, ok := c.(*config.FullNode) if !ok { return xerrors.Errorf("invalid config from repo, got: %T", c) } - cfg = &cfgp.Blockstore + cfg = &cfgp.Chainstore default: - cfg = &config.Blockstore{} + cfg = &config.Chainstore{} } return Options( @@ -605,7 +605,7 @@ func Repo(r repo.Repo) Option { Override(new(dtypes.UniversalBlockstore), modules.UniversalBlockstore), If(cfg.EnableSplitstore, - If(cfg.Splitstore.GetHotStoreType() == "badger", + If(cfg.Splitstore.HotStoreType == "badger", Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)), Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)), Override(new(dtypes.ChainBlockstore), modules.ChainSplitBlockstore), diff --git a/node/config/def.go b/node/config/def.go index 3aff08468..5e1b14128 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -12,19 +12,19 @@ import ( // Common is common config between full node and miner type Common struct { - API API - Libp2p Libp2p - Pubsub Pubsub - Blockstore Blockstore + API API + Libp2p Libp2p + Pubsub Pubsub } // FullNode is a full node config type FullNode struct { Common - Client Client - Metrics Metrics - Wallet Wallet - Fees FeeConfig + Client Client + Metrics Metrics + Wallet Wallet + Fees FeeConfig + Chainstore Chainstore } // // Common @@ -120,7 +120,7 @@ type Pubsub struct { RemoteTracer string } -type Blockstore struct { +type Chainstore struct { EnableSplitstore bool Splitstore Splitstore } @@ -134,14 +134,6 @@ type Splitstore struct { Archival bool } -func (s *Splitstore) GetHotStoreType() string { - // default is badger - if s.HotStoreType == "" { - return "badger" - } - return s.HotStoreType -} - // // Full Node type Metrics struct { @@ -207,6 +199,12 @@ func DefaultFullNode() *FullNode { Client: Client{ SimultaneousTransfers: DefaultSimultaneousTransfers, }, + Chainstore: Chainstore{ + EnableSplitstore: false, + Splitstore: Splitstore{ + HotStoreType: "badger", + }, + }, } } diff --git a/node/modules/blockstore.go b/node/modules/blockstore.go index 500fcffcd..c85010f40 100644 --- a/node/modules/blockstore.go +++ b/node/modules/blockstore.go @@ -67,7 +67,7 @@ func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlocksto return hot, err } -func SplitBlockstore(cfg *config.Blockstore) func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.UniversalBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) { +func SplitBlockstore(cfg *config.Chainstore) func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.UniversalBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) { return func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.UniversalBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) { path, err := r.SplitstorePath() if err != nil {