refactor: have rpc and contract prices be in SC as they are expected to change very rarely

This commit is contained in:
Derrick Hammer 2024-03-10 14:26:17 -04:00
parent 1568aa9007
commit af29081a3a
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 16 additions and 16 deletions

View File

@ -12,8 +12,8 @@ type SiaConfig struct {
MaxUploadPrice float64 `mapstructure:"max_upload_price"`
MaxDownloadPrice float64 `mapstructure:"max_download_price"`
MaxStoragePrice float64 `mapstructure:"max_storage_price"`
MaxContractPrice float64 `mapstructure:"max_contract_price"`
MaxRPCPrice float64 `mapstructure:"max_rpc_price"`
MaxContractSCPrice float64 `mapstructure:"max_contract_sc_price"`
MaxRPCSCPrice float64 `mapstructure:"max_rpc_sc_price"`
}
func (s SiaConfig) Defaults() map[string]interface{} {
@ -43,12 +43,12 @@ func (s SiaConfig) Validate() error {
return errors.New("core.storage.sia.max_storage_price must be greater than 0")
}
if s.MaxContractPrice <= 0 {
return errors.New("core.storage.sia.max_contract_price must be greater than 0")
if s.MaxRPCSCPrice <= 0 {
return errors.New("core.storage.sia.max_rpc_sc_price must be greater than 0")
}
if s.MaxRPCPrice <= 0 {
return errors.New("core.storage.sia.max_rpc_price must be greater than 0")
if s.MaxRPCSCPrice <= 0 {
return errors.New("core.storage.sia.max_contract_sc_price must be greater than 0")
}
return nil

View File

@ -128,20 +128,20 @@ SELECT AVG(rate) as average_rate FROM (
return err
}
maxContractPrice := p.config.Config().Core.Storage.Sia.MaxContractPrice / averageRate
maxContractPrice := p.config.Config().Core.Storage.Sia.MaxContractSCPrice
p.logger.Debug("Setting max contract price", zap.Float64("maxContractPrice", maxContractPrice))
gouge.MaxContractPrice, err = siacoinsFromFloat(p.config.Config().Core.Storage.Sia.MaxContractPrice / averageRate)
gouge.MaxContractPrice, err = siacoinsFromFloat(maxContractPrice)
if err != nil {
return err
}
maxRPCPrice := p.config.Config().Core.Storage.Sia.MaxRPCPrice / averageRate
maxRPCPrice := p.config.Config().Core.Storage.Sia.MaxRPCSCPrice / averageRate
p.logger.Debug("Setting max RPC price", zap.Float64("maxRPCPrice", maxRPCPrice))
gouge.MaxRPCPrice, err = siacoinsFromFloat(p.config.Config().Core.Storage.Sia.MaxRPCPrice / averageRate)
gouge.MaxRPCPrice, err = siacoinsFromFloat(maxRPCPrice)
if err != nil {
return err
}