move Blockstore config to FullNode, rename to Chainstore and add default for HotStoreType
This commit is contained in:
parent
6014273e69
commit
dd0c308427
@ -586,16 +586,16 @@ func Repo(r repo.Repo) Option {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var cfg *config.Blockstore
|
var cfg *config.Chainstore
|
||||||
switch settings.nodeType {
|
switch settings.nodeType {
|
||||||
case repo.FullNode:
|
case repo.FullNode:
|
||||||
cfgp, ok := c.(*config.FullNode)
|
cfgp, ok := c.(*config.FullNode)
|
||||||
if !ok {
|
if !ok {
|
||||||
return xerrors.Errorf("invalid config from repo, got: %T", c)
|
return xerrors.Errorf("invalid config from repo, got: %T", c)
|
||||||
}
|
}
|
||||||
cfg = &cfgp.Blockstore
|
cfg = &cfgp.Chainstore
|
||||||
default:
|
default:
|
||||||
cfg = &config.Blockstore{}
|
cfg = &config.Chainstore{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Options(
|
return Options(
|
||||||
@ -605,7 +605,7 @@ func Repo(r repo.Repo) Option {
|
|||||||
Override(new(dtypes.UniversalBlockstore), modules.UniversalBlockstore),
|
Override(new(dtypes.UniversalBlockstore), modules.UniversalBlockstore),
|
||||||
|
|
||||||
If(cfg.EnableSplitstore,
|
If(cfg.EnableSplitstore,
|
||||||
If(cfg.Splitstore.GetHotStoreType() == "badger",
|
If(cfg.Splitstore.HotStoreType == "badger",
|
||||||
Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)),
|
Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)),
|
||||||
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)),
|
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)),
|
||||||
Override(new(dtypes.ChainBlockstore), modules.ChainSplitBlockstore),
|
Override(new(dtypes.ChainBlockstore), modules.ChainSplitBlockstore),
|
||||||
|
@ -12,19 +12,19 @@ import (
|
|||||||
|
|
||||||
// Common is common config between full node and miner
|
// Common is common config between full node and miner
|
||||||
type Common struct {
|
type Common struct {
|
||||||
API API
|
API API
|
||||||
Libp2p Libp2p
|
Libp2p Libp2p
|
||||||
Pubsub Pubsub
|
Pubsub Pubsub
|
||||||
Blockstore Blockstore
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FullNode is a full node config
|
// FullNode is a full node config
|
||||||
type FullNode struct {
|
type FullNode struct {
|
||||||
Common
|
Common
|
||||||
Client Client
|
Client Client
|
||||||
Metrics Metrics
|
Metrics Metrics
|
||||||
Wallet Wallet
|
Wallet Wallet
|
||||||
Fees FeeConfig
|
Fees FeeConfig
|
||||||
|
Chainstore Chainstore
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Common
|
// // Common
|
||||||
@ -120,7 +120,7 @@ type Pubsub struct {
|
|||||||
RemoteTracer string
|
RemoteTracer string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Blockstore struct {
|
type Chainstore struct {
|
||||||
EnableSplitstore bool
|
EnableSplitstore bool
|
||||||
Splitstore Splitstore
|
Splitstore Splitstore
|
||||||
}
|
}
|
||||||
@ -134,14 +134,6 @@ type Splitstore struct {
|
|||||||
Archival bool
|
Archival bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Splitstore) GetHotStoreType() string {
|
|
||||||
// default is badger
|
|
||||||
if s.HotStoreType == "" {
|
|
||||||
return "badger"
|
|
||||||
}
|
|
||||||
return s.HotStoreType
|
|
||||||
}
|
|
||||||
|
|
||||||
// // Full Node
|
// // Full Node
|
||||||
|
|
||||||
type Metrics struct {
|
type Metrics struct {
|
||||||
@ -207,6 +199,12 @@ func DefaultFullNode() *FullNode {
|
|||||||
Client: Client{
|
Client: Client{
|
||||||
SimultaneousTransfers: DefaultSimultaneousTransfers,
|
SimultaneousTransfers: DefaultSimultaneousTransfers,
|
||||||
},
|
},
|
||||||
|
Chainstore: Chainstore{
|
||||||
|
EnableSplitstore: false,
|
||||||
|
Splitstore: Splitstore{
|
||||||
|
HotStoreType: "badger",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlocksto
|
|||||||
return hot, err
|
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) {
|
return func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.UniversalBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) {
|
||||||
path, err := r.SplitstorePath()
|
path, err := r.SplitstorePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user