refactor: fetch redundancy settings and divide on it so price is always the total
This commit is contained in:
parent
c9683453c0
commit
21ae6d093d
|
@ -95,18 +95,32 @@ SELECT AVG(rate) as average_rate FROM (
|
||||||
return errors.New("average rate is 0")
|
return errors.New("average rate is 0")
|
||||||
}
|
}
|
||||||
|
|
||||||
gouge, err := p.renter.GougingSettings(context.Background())
|
ctx := context.Background()
|
||||||
|
|
||||||
|
gouge, err := p.renter.GougingSettings(ctx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.logger.Error("failed to fetch gouging settings", zap.Error(err))
|
p.logger.Error("failed to fetch gouging settings", zap.Error(err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
gouge.MaxDownloadPrice, err = siacoinsFromFloat(p.config.Config().Core.Storage.Sia.MaxDownloadPrice / averageRate)
|
redundancy, err := p.renter.RedundancySettings(ctx)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
p.logger.Error("failed to fetch redundancy settings", zap.Error(err))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
maxDownloadPrice := p.config.Config().Core.Storage.Sia.MaxDownloadPrice / averageRate
|
||||||
|
maxDownloadPrice = maxDownloadPrice / redundancy.Redundancy()
|
||||||
|
|
||||||
|
maxDownloadPriceSc, err := siacoinsFromFloat(maxDownloadPrice)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gouge.MaxDownloadPrice = maxDownloadPriceSc
|
||||||
|
|
||||||
gouge.MaxUploadPrice, err = siacoinsFromFloat(p.config.Config().Core.Storage.Sia.MaxUploadPrice / averageRate)
|
gouge.MaxUploadPrice, err = siacoinsFromFloat(p.config.Config().Core.Storage.Sia.MaxUploadPrice / averageRate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue