move Blockstore config to FullNode, rename to Chainstore and add default for HotStoreType

This commit is contained in:
vyzo 2021-03-02 15:45:36 +02:00
parent 6014273e69
commit dd0c308427
3 changed files with 20 additions and 22 deletions

View File

@ -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),

View File

@ -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",
},
},
}
}

View File

@ -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 {