refactor: have rpc and contract prices be in SC as they are expected to change very rarely
This commit is contained in:
parent
1568aa9007
commit
af29081a3a
|
@ -6,14 +6,14 @@ var _ Validator = (*SiaConfig)(nil)
|
||||||
var _ Defaults = (*SiaConfig)(nil)
|
var _ Defaults = (*SiaConfig)(nil)
|
||||||
|
|
||||||
type SiaConfig struct {
|
type SiaConfig struct {
|
||||||
Key string `mapstructure:"key"`
|
Key string `mapstructure:"key"`
|
||||||
URL string `mapstructure:"url"`
|
URL string `mapstructure:"url"`
|
||||||
PriceHistoryDays uint64 `mapstructure:"price_history_days"`
|
PriceHistoryDays uint64 `mapstructure:"price_history_days"`
|
||||||
MaxUploadPrice float64 `mapstructure:"max_upload_price"`
|
MaxUploadPrice float64 `mapstructure:"max_upload_price"`
|
||||||
MaxDownloadPrice float64 `mapstructure:"max_download_price"`
|
MaxDownloadPrice float64 `mapstructure:"max_download_price"`
|
||||||
MaxStoragePrice float64 `mapstructure:"max_storage_price"`
|
MaxStoragePrice float64 `mapstructure:"max_storage_price"`
|
||||||
MaxContractPrice float64 `mapstructure:"max_contract_price"`
|
MaxContractSCPrice float64 `mapstructure:"max_contract_sc_price"`
|
||||||
MaxRPCPrice float64 `mapstructure:"max_rpc_price"`
|
MaxRPCSCPrice float64 `mapstructure:"max_rpc_sc_price"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s SiaConfig) Defaults() map[string]interface{} {
|
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")
|
return errors.New("core.storage.sia.max_storage_price must be greater than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.MaxContractPrice <= 0 {
|
if s.MaxRPCSCPrice <= 0 {
|
||||||
return errors.New("core.storage.sia.max_contract_price must be greater than 0")
|
return errors.New("core.storage.sia.max_rpc_sc_price must be greater than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.MaxRPCPrice <= 0 {
|
if s.MaxRPCSCPrice <= 0 {
|
||||||
return errors.New("core.storage.sia.max_rpc_price must be greater than 0")
|
return errors.New("core.storage.sia.max_contract_sc_price must be greater than 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -128,20 +128,20 @@ SELECT AVG(rate) as average_rate FROM (
|
||||||
return err
|
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))
|
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 {
|
if err != nil {
|
||||||
return err
|
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))
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue