[#598] innerring/config: Override global config only in debug build

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-06-09 14:00:55 +03:00 committed by Alex Vanin
parent b55a2959c5
commit e50abeab0c

View file

@ -13,6 +13,7 @@ Implemented as a part of https://github.com/nspcc-dev/neofs-node/issues/363
*/ */
import ( import (
"github.com/nspcc-dev/neofs-node/misc"
netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper" netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
"github.com/spf13/viper" "github.com/spf13/viper"
) )
@ -30,27 +31,33 @@ func NewGlobalConfigReader(cfg *viper.Viper, nm *netmapClient.Wrapper) *GlobalCo
} }
func (c *GlobalConfig) BasicIncomeRate() (uint64, error) { func (c *GlobalConfig) BasicIncomeRate() (uint64, error) {
value := c.cfg.GetUint64("settlement.basic_income_rate") if isDebug() {
if value != 0 { value := c.cfg.GetUint64("settlement.basic_income_rate")
return value, nil if value != 0 {
return value, nil
}
} }
return c.nm.BasicIncomeRate() return c.nm.BasicIncomeRate()
} }
func (c *GlobalConfig) AuditFee() (uint64, error) { func (c *GlobalConfig) AuditFee() (uint64, error) {
value := c.cfg.GetUint64("settlement.audit_fee") if isDebug() {
if value != 0 { value := c.cfg.GetUint64("settlement.audit_fee")
return value, nil if value != 0 {
return value, nil
}
} }
return c.nm.AuditFee() return c.nm.AuditFee()
} }
func (c *GlobalConfig) EpochDuration() (uint32, error) { func (c *GlobalConfig) EpochDuration() (uint32, error) {
value := c.cfg.GetUint32("timers.epoch") if isDebug() {
if value != 0 { value := c.cfg.GetUint32("timers.epoch")
return value, nil if value != 0 {
return value, nil
}
} }
epochDuration, err := c.nm.EpochDuration() epochDuration, err := c.nm.EpochDuration()
@ -60,3 +67,7 @@ func (c *GlobalConfig) EpochDuration() (uint32, error) {
return uint32(epochDuration), nil return uint32(epochDuration), nil
} }
func isDebug() bool {
return misc.Debug == "true"
}