fix(runtime/v2): provide default factory options if unset in app builder (#21690)
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
type AppBuilder[T transaction.Tx] struct {
|
||||
app *App[T]
|
||||
config server.DynamicConfig
|
||||
storeOptions rootstore.Options
|
||||
storeOptions *rootstore.Options
|
||||
|
||||
// the following fields are used to overwrite the default
|
||||
branch func(state store.ReaderMap) store.WriterMap
|
||||
@@ -131,10 +131,16 @@ func (a *AppBuilder[T]) Build(opts ...AppBuilderOption[T]) (*App[T], error) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var storeOptions rootstore.Options
|
||||
if a.storeOptions != nil {
|
||||
storeOptions = *a.storeOptions
|
||||
} else {
|
||||
storeOptions = rootstore.DefaultStoreOptions()
|
||||
}
|
||||
factoryOptions := &rootstore.FactoryOptions{
|
||||
Logger: a.app.logger,
|
||||
RootDir: home,
|
||||
Options: a.storeOptions,
|
||||
Options: storeOptions,
|
||||
StoreKeys: append(a.app.storeKeys, "stf"),
|
||||
SCRawDB: scRawDb,
|
||||
}
|
||||
@@ -216,7 +222,7 @@ func AppBuilderWithPostTxExec[T transaction.Tx](postTxExec func(ctx context.Cont
|
||||
}
|
||||
}
|
||||
|
||||
func AppBuilderWithStoreOptions[T transaction.Tx](opts rootstore.Options) AppBuilderOption[T] {
|
||||
func AppBuilderWithStoreOptions[T transaction.Tx](opts *rootstore.Options) AppBuilderOption[T] {
|
||||
return func(a *AppBuilder[T]) {
|
||||
a.storeOptions = opts
|
||||
}
|
||||
|
||||
+5
-3
@@ -100,7 +100,7 @@ func NewSimApp[T transaction.Tx](
|
||||
app = &SimApp[T]{}
|
||||
appBuilder *runtime.AppBuilder[T]
|
||||
err error
|
||||
storeOptions = root.DefaultStoreOptions()
|
||||
storeOptions = &root.Options{}
|
||||
|
||||
// merge the AppConfig and other configuration in one config
|
||||
appConfig = depinject.Configs(
|
||||
@@ -190,13 +190,15 @@ func NewSimApp[T transaction.Tx](
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var builderOpts []runtime.AppBuilderOption[T]
|
||||
if sub := viper.Sub("store.options"); sub != nil {
|
||||
err = sub.Unmarshal(&storeOptions)
|
||||
err = sub.Unmarshal(storeOptions)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
builderOpts = append(builderOpts, runtime.AppBuilderWithStoreOptions[T](storeOptions))
|
||||
}
|
||||
app.App, err = appBuilder.Build(runtime.AppBuilderWithStoreOptions[T](storeOptions))
|
||||
app.App, err = appBuilder.Build(builderOpts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@@ -34,13 +34,9 @@ import (
|
||||
v2 "github.com/cosmos/cosmos-sdk/x/genutil/v2/cli"
|
||||
)
|
||||
|
||||
func newApp[T transaction.Tx](
|
||||
logger log.Logger, viper *viper.Viper,
|
||||
) serverv2.AppI[T] {
|
||||
func newApp[T transaction.Tx](logger log.Logger, viper *viper.Viper) serverv2.AppI[T] {
|
||||
viper.Set(serverv2.FlagHome, simapp.DefaultNodeHome)
|
||||
|
||||
return serverv2.AppI[T](
|
||||
simapp.NewSimApp[T](logger, viper))
|
||||
return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper))
|
||||
}
|
||||
|
||||
func initRootCmd[T transaction.Tx](
|
||||
|
||||
Reference in New Issue
Block a user