hook noop blockstore for splitstore in DI
This commit is contained in:
parent
4d3c73f4ca
commit
5cca29d1db
@ -643,6 +643,10 @@ 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.ColdStoreType == "universal",
|
||||||
|
Override(new(dtypes.ColdBlockstore), From(new(dtypes.UniversalBlockstore)))),
|
||||||
|
If(cfg.Splitstore.ColdStoreType == "noop",
|
||||||
|
Override(new(dtypes.ColdBlockstore), modules.NoopColdBlockstore)),
|
||||||
If(cfg.Splitstore.HotStoreType == "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)),
|
||||||
|
@ -229,6 +229,7 @@ type Chainstore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Splitstore struct {
|
type Splitstore struct {
|
||||||
|
ColdStoreType string
|
||||||
HotStoreType string
|
HotStoreType string
|
||||||
TrackingStoreType string
|
TrackingStoreType string
|
||||||
MarkSetType string
|
MarkSetType string
|
||||||
@ -305,7 +306,8 @@ func DefaultFullNode() *FullNode {
|
|||||||
Chainstore: Chainstore{
|
Chainstore: Chainstore{
|
||||||
EnableSplitstore: false,
|
EnableSplitstore: false,
|
||||||
Splitstore: Splitstore{
|
Splitstore: Splitstore{
|
||||||
HotStoreType: "badger",
|
ColdStoreType: "universal",
|
||||||
|
HotStoreType: "badger",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,10 @@ func UniversalBlockstore(lc fx.Lifecycle, mctx helpers.MetricsCtx, r repo.Locked
|
|||||||
return bs, err
|
return bs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NoopColdBlockstore(lc fx.Lifecycle, bs dtypes.UniversalBlockstore) (dtypes.ColdBlockstore, error) {
|
||||||
|
return blockstore.NewNoopStore(bs), nil
|
||||||
|
}
|
||||||
|
|
||||||
func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlockstore, error) {
|
func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlockstore, error) {
|
||||||
path, err := r.SplitstorePath()
|
path, err := r.SplitstorePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,8 +70,8 @@ func BadgerHotBlockstore(lc fx.Lifecycle, r repo.LockedRepo) (dtypes.HotBlocksto
|
|||||||
return bs, nil
|
return bs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SplitBlockstore(cfg *config.Chainstore) 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.ColdBlockstore, 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.ColdBlockstore, hot dtypes.HotBlockstore) (dtypes.SplitBlockstore, error) {
|
||||||
path, err := r.SplitstorePath()
|
path, err := r.SplitstorePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -24,9 +24,12 @@ import (
|
|||||||
type MetadataDS datastore.Batching
|
type MetadataDS datastore.Batching
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// UniversalBlockstore is the cold blockstore.
|
// UniversalBlockstore is the universal blockstore backend.
|
||||||
UniversalBlockstore blockstore.Blockstore
|
UniversalBlockstore blockstore.Blockstore
|
||||||
|
|
||||||
|
// ColdBlockstore is the Cold blockstore abstraction for the splitstore
|
||||||
|
ColdBlockstore blockstore.Blockstore
|
||||||
|
|
||||||
// HotBlockstore is the Hot blockstore abstraction for the splitstore
|
// HotBlockstore is the Hot blockstore abstraction for the splitstore
|
||||||
HotBlockstore blockstore.Blockstore
|
HotBlockstore blockstore.Blockstore
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user