refactor(server): alias AppOptions to coreserver.DynamicConfig (backport #21711) (#21722)

This commit is contained in:
mergify[bot] 2024-09-13 21:18:30 +02:00 committed by GitHub
parent 21303e2780
commit 45b18a1045
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/gogoproto/grpc"
"cosmossdk.io/core/server"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/store/snapshots"
@ -26,9 +27,7 @@ type (
// literal defined on the server Context. Note, casting Get calls may not yield
// the expected types and could result in type assertion errors. It is recommend
// to either use the cast package or perform manual conversion for safety.
AppOptions interface {
Get(string) interface{}
}
AppOptions = server.DynamicConfig
// Application defines an application interface that wraps abci.Application.
// The interface defines the necessary contracts to be implemented in order

View File

@ -492,4 +492,8 @@ func (m mapGetter) Get(key string) interface{} {
return m[key]
}
func (m mapGetter) GetString(key string) string {
return m[key].(string)
}
var _ servertypes.AppOptions = mapGetter{}

View File

@ -306,6 +306,15 @@ func (m AppOptionsMap) Get(key string) interface{} {
return v
}
func (m AppOptionsMap) GetString(key string) string {
v, ok := m[key]
if !ok {
return ""
}
return v.(string)
}
func NewAppOptionsWithFlagHome(homePath string) servertypes.AppOptions {
return AppOptionsMap{
flags.FlagHome: homePath,

View File

@ -235,6 +235,10 @@ func (f AppOptionsFn) Get(k string) any {
return f(k)
}
func (f AppOptionsFn) GetString(k string) string {
return f(k).(string)
}
// FauxMerkleModeOpt returns a BaseApp option to use a dbStoreAdapter instead of
// an IAVLStore for faster simulation speed.
func FauxMerkleModeOpt(bapp *baseapp.BaseApp) {