feat!: Add object store (#25470)
Co-authored-by: yihuang <huang@crypto.com> Co-authored-by: mmsqe <mavis@crypto.com> Co-authored-by: mmsqe <tqd0800210105@gmail.com> Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
This commit is contained in:
co-authored by
yihuang
mmsqe
mmsqe
Tyler
parent
5e022baf9b
commit
d790942c42
@@ -283,6 +283,9 @@ func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) {
|
||||
case *storetypes.MemoryStoreKey:
|
||||
app.MountStore(key, storetypes.StoreTypeMemory)
|
||||
|
||||
case *storetypes.ObjectStoreKey:
|
||||
app.MountStore(key, storetypes.StoreTypeObject)
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("Unrecognized store key type :%T", key))
|
||||
}
|
||||
@@ -321,6 +324,16 @@ func (app *BaseApp) MountMemoryStores(keys map[string]*storetypes.MemoryStoreKey
|
||||
}
|
||||
}
|
||||
|
||||
// MountObjectStores mounts all transient object stores with the BaseApp's internal
|
||||
// commit multi-store.
|
||||
func (app *BaseApp) MountObjectStores(keys map[string]*storetypes.ObjectStoreKey) {
|
||||
skeys := slices.Sorted(maps.Keys(keys))
|
||||
for _, key := range skeys {
|
||||
memKey := keys[key]
|
||||
app.MountStore(memKey, storetypes.StoreTypeObject)
|
||||
}
|
||||
}
|
||||
|
||||
// MountStore mounts a store to the provided key in the BaseApp multistore,
|
||||
// using the default DB.
|
||||
func (app *BaseApp) MountStore(key storetypes.StoreKey, typ storetypes.StoreType) {
|
||||
|
||||
@@ -988,6 +988,25 @@ func TestGetEmptyConsensusParams(t *testing.T) {
|
||||
require.Equal(t, uint64(0), suite.baseApp.GetMaximumBlockGas(ctx))
|
||||
}
|
||||
|
||||
func TestMountStores(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
db := dbm.NewMemDB()
|
||||
name := t.Name()
|
||||
app := baseapp.NewBaseApp(name, logger, db, nil)
|
||||
kvKey := storetypes.NewKVStoreKey("kv")
|
||||
transKey := storetypes.NewTransientStoreKey("trans")
|
||||
memKey := storetypes.NewMemoryStoreKey("mem")
|
||||
objKey := storetypes.NewObjectStoreKey("obj")
|
||||
app.MountStores(kvKey, transKey, memKey, objKey)
|
||||
objKey2 := storetypes.NewObjectStoreKey("obj2")
|
||||
app.MountObjectStores(map[string]*storetypes.ObjectStoreKey{"obj2": objKey2})
|
||||
require.NoError(t, app.LoadLatestVersion())
|
||||
for _, keyName := range []storetypes.StoreKey{kvKey, transKey, memKey, objKey} {
|
||||
require.NotNil(t, app.CommitMultiStore().GetStore(keyName))
|
||||
}
|
||||
require.NotNil(t, app.CommitMultiStore().GetStore(objKey2))
|
||||
}
|
||||
|
||||
func TestLoadVersionPruning(t *testing.T) {
|
||||
logger := log.NewNopLogger()
|
||||
pruningOptions := pruningtypes.NewCustomPruningOptions(10, 15)
|
||||
|
||||
Reference in New Issue
Block a user