Skip to content

Commit

Permalink
add MinGasPrices check in interceptConfigs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberbono3 committed May 26, 2021
1 parent ef14cc8 commit c85f811
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
6 changes: 1 addition & 5 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,7 @@ which accepts a path for the resulting pprof file.
serverCtx.Logger.Info("starting ABCI without Tendermint")
return startStandAlone(serverCtx, appCreator)
}

if flagMinGasPricesStr, _ := cmd.Flags().GetString(FlagMinGasPrices); flagMinGasPricesStr == "" {
return fmt.Errorf("FlagMinGasPrices must not be empty")
}


serverCtx.Logger.Info("starting ABCI with Tendermint")

// amino is needed here for backwards compatibility of REST routes
Expand Down
38 changes: 37 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,23 +224,59 @@ func interceptConfigs(rootViper *viper.Viper) (*tmcfg.Config, error) {

conf.SetRoot(rootDir)

appCfgFilePath := filepath.Join(configPath, "app.toml")

appConf, err := config.ParseConfig(rootViper)
if err != nil {
return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err)
}

if _, err := os.Stat(appCfgFilePath); os.IsNotExist(err) {
config.WriteConfigFile(appCfgFilePath, appConf)
}

// app.toml config file exist
rootViper.SetConfigType("toml")
rootViper.SetConfigName("app")
rootViper.AddConfigPath(configPath)

// reading config from app.toml
if err := rootViper.ReadInConfig(); err != nil {
return nil, err
}
// unmarshalling to appConf
if err := rootViper.Unmarshal(appConf); err != nil {
return nil, err
}
// TODO play with prefixes envVars and flags
if appConf.BaseConfig.MinGasPrices == ""{
return nil, fmt.Errorf("MinGasPrices must not be empty")
}

if err := rootViper.MergeInConfig(); err != nil {
return nil, fmt.Errorf("failed to merge configuration: %w", err)
}

/*
appCfgFilePath := filepath.Join(configPath, "app.toml")
if _, err := os.Stat(appCfgFilePath); os.IsNotExist(err) {
appConf, err := config.ParseConfig(rootViper)
if err != nil {
return nil, fmt.Errorf("failed to parse %s: %w", appCfgFilePath, err)
}

config.WriteConfigFile(appCfgFilePath, appConf)
}
rootViper.SetConfigType("toml")
rootViper.SetConfigName("app")
rootViper.AddConfigPath(configPath)
if err := rootViper.MergeInConfig(); err != nil {
return nil, fmt.Errorf("failed to merge configuration: %w", err)
}
*/

return conf, nil
}
Expand Down

0 comments on commit c85f811

Please sign in to comment.