Skip to content

Commit

Permalink
add deprecated cmt
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuvubk committed May 23, 2024
1 parent baae5d4 commit 5de4f6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
26 changes: 8 additions & 18 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,6 @@ const (
KeyTriggerTestnetUpgrade = "trigger-testnet-upgrade"
)

// Keep Context type
type Context struct {
Viper *viper.Viper
Logger log.Logger
}

// StartCmdOptions defines options that can be customized in `StartCmdWithOptions`,
type StartCmdOptions[T types.Application] struct {
// DBOpener can be used to customize db opening, for example customize db options or support different db backends,
Expand Down Expand Up @@ -706,12 +700,8 @@ you want to test the upgrade handler itself.
RunE: func(cmd *cobra.Command, args []string) error {
viper := client.GetViperFromCmd(cmd)
logger := client.GetLoggerFromCmd(cmd)
serverCtx := &Context{
Viper: viper,
Logger: logger,
}

_, err := GetPruningOptionsFromFlags(serverCtx.Viper)
_, err := GetPruningOptionsFromFlags(viper)
if err != nil {
return err
}
Expand All @@ -723,7 +713,7 @@ you want to test the upgrade handler itself.

withCMT, _ := cmd.Flags().GetBool(flagWithComet)
if !withCMT {
serverCtx.Logger.Info("starting ABCI without CometBFT")
logger.Info("starting ABCI without CometBFT")
}

newChainID := args[0]
Expand All @@ -745,20 +735,20 @@ you want to test the upgrade handler itself.

// Set testnet keys to be used by the application.
// This is done to prevent changes to existing start API.
serverCtx.Viper.Set(KeyIsTestnet, true)
serverCtx.Viper.Set(KeyNewChainID, newChainID)
serverCtx.Viper.Set(KeyNewOpAddr, newOperatorAddress)
viper.Set(KeyIsTestnet, true)
viper.Set(KeyNewChainID, newChainID)
viper.Set(KeyNewOpAddr, newOperatorAddress)

err = wrapCPUProfile(viper, logger, func() error {
return opts.StartCommandHandler(viper, logger, clientCtx, testnetAppCreator, withCMT, opts)
})

serverCtx.Logger.Debug("received quit signal")
logger.Debug("received quit signal")
graceDuration, _ := cmd.Flags().GetDuration(FlagShutdownGrace)
if graceDuration > 0 {
serverCtx.Logger.Info("graceful shutdown start", FlagShutdownGrace, graceDuration)
logger.Info("graceful shutdown start", FlagShutdownGrace, graceDuration)
<-time.After(graceDuration)
serverCtx.Logger.Info("graceful shutdown complete")
logger.Info("graceful shutdown complete")
}

return err
Expand Down
8 changes: 4 additions & 4 deletions server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
)

// Keep Context type as LegacyContext
type LegacyContext struct {
// Deprecated: Do not use, we use viper to track all config
type Context struct {
Viper *viper.Viper
Logger log.Logger
Config *cmtcfg.Config
Expand Down Expand Up @@ -185,8 +185,8 @@ func CreateSDKLogger(v *viper.Viper, out io.Writer) (log.Logger, error) {

// GetServerContextFromCmd returns a Context from a command or an empty Context
// if it has not been set.
func GetServerContextFromCmd(cmd *cobra.Command) *LegacyContext {
serverCtx := &LegacyContext{}
func GetServerContextFromCmd(cmd *cobra.Command) *Context {
serverCtx := &Context{}
if v := cmd.Context().Value(corectx.ViperContextKey{}); v != nil {
viper := v.(*viper.Viper)
serverCtx.Viper = viper
Expand Down

0 comments on commit 5de4f6c

Please sign in to comment.