50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
const (
|
|
defaultMinGasPrices = ""
|
|
)
|
|
|
|
// BaseConfig defines the server's basic configuration
|
|
type BaseConfig struct {
|
|
// The minimum gas prices a validator is willing to accept for processing a
|
|
// transaction. A transaction's fees must meet the minimum of each denomination
|
|
// specified in this config (e.g. 0.01photino,0.0001stake).
|
|
MinGasPrices string `mapstructure:"minimum_gas_prices"`
|
|
}
|
|
|
|
// Config defines the server's top level configuration
|
|
type Config struct {
|
|
BaseConfig `mapstructure:",squash"`
|
|
}
|
|
|
|
// SetMinGasPrices sets the validator's minimum gas prices.
|
|
func (c *Config) SetMinGasPrices(gasPrices sdk.DecCoins) {
|
|
c.MinGasPrices = gasPrices.String()
|
|
}
|
|
|
|
// GetMinGasPrices returns the validator's minimum gas prices based on the set
|
|
// configuration.
|
|
func (c *Config) GetMinGasPrices() sdk.DecCoins {
|
|
gasPrices, err := sdk.ParseDecCoins(c.MinGasPrices)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("invalid minimum gas prices: %v", err))
|
|
}
|
|
|
|
return gasPrices
|
|
}
|
|
|
|
// DefaultConfig returns server's default configuration.
|
|
func DefaultConfig() *Config {
|
|
return &Config{
|
|
BaseConfig{
|
|
MinGasPrices: defaultMinGasPrices,
|
|
},
|
|
}
|
|
}
|