propagate useLMDB option to splitstore through DI

This commit is contained in:
vyzo 2021-02-27 12:10:10 +02:00
parent 923a3db4b0
commit 68b6f913c7
4 changed files with 23 additions and 22 deletions

View File

@ -25,5 +25,5 @@ func NewLiveSetEnv(path string, useLMDB bool) (LiveSetEnv, error) {
return NewLMDBLiveSetEnv(filepath.Join(path, "sweep.lmdb"))
}
return nil, fmt.Errorf("FIXME: non-lmdb livesets")
return nil, fmt.Errorf("TODO: non-lmdb livesets")
}

View File

@ -31,8 +31,6 @@ const (
var baseEpochKey = dstore.NewKey("baseEpoch")
var UseLMDB = true // TODO snake this through DI
var log = logging.Logger("splitstore")
func init() {
@ -66,15 +64,15 @@ var _ bstore.Blockstore = (*SplitStore)(nil)
// NewSplitStore creates a new SplitStore instance, given a path for the hotstore dbs and a cold
// blockstore. The SplitStore must be attached to the ChainStore with Start in order to trigger
// compaction.
func NewSplitStore(path string, ds dstore.Datastore, cold, hot bstore.Blockstore) (*SplitStore, error) {
func NewSplitStore(path string, ds dstore.Datastore, cold, hot bstore.Blockstore, useLMDB bool) (*SplitStore, error) {
// the tracking store
snoop, err := NewTrackingStore(path, UseLMDB)
snoop, err := NewTrackingStore(path, useLMDB)
if err != nil {
return nil, err
}
// the liveset env
env, err := NewLiveSetEnv(path, UseLMDB)
env, err := NewLiveSetEnv(path, useLMDB)
if err != nil {
snoop.Close() //nolint:errcheck
return nil, err

View File

@ -615,7 +615,7 @@ func Repo(r repo.Repo) Option {
Override(new(dtypes.HotBlockstore), modules.LMDBHotBlockstore)),
If(!cfg.UseLMDB,
Override(new(dtypes.HotBlockstore), modules.BadgerHotBlockstore)),
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore),
Override(new(dtypes.SplitBlockstore), modules.SplitBlockstore(cfg)),
Override(new(dtypes.ChainBlockstore), modules.ChainSplitBlockstore),
Override(new(dtypes.StateBlockstore), modules.StateSplitBlockstore),
Override(new(dtypes.BaseBlockstore), From(new(dtypes.SplitBlockstore))),

View File

@ -15,6 +15,7 @@ import (
"github.com/filecoin-project/lotus/blockstore"
"github.com/filecoin-project/lotus/chain/store/splitstore"
"github.com/filecoin-project/lotus/node/config"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/lotus/node/modules/helpers"
"github.com/filecoin-project/lotus/node/repo"
@ -95,23 +96,25 @@ func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlocksto
return hot, err
}
func SplitBlockstore(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.ColdBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) {
path, err := r.SplitstorePath()
if err != nil {
return nil, err
}
func SplitBlockstore(cfg *config.Blockstore) func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.ColdBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) {
return func(lc fx.Lifecycle, r repo.LockedRepo, ds dtypes.MetadataDS, cold dtypes.ColdBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) {
path, err := r.SplitstorePath()
if err != nil {
return nil, err
}
ss, err := splitstore.NewSplitStore(path, ds, cold, hot)
if err != nil {
return nil, err
}
lc.Append(fx.Hook{
OnStop: func(context.Context) error {
return ss.Close()
},
})
ss, err := splitstore.NewSplitStore(path, ds, cold, hot, cfg.UseLMDB)
if err != nil {
return nil, err
}
lc.Append(fx.Hook{
OnStop: func(context.Context) error {
return ss.Close()
},
})
return ss, err
return ss, err
}
}
func StateFlatBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, bs dtypes.ColdBlockstore) (dtypes.StateBlockstore, error) {