[#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 (
"github.com/nspcc-dev/neofs-node/misc"
netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap/wrapper"
"github.com/spf13/viper"
)
@ -30,28 +31,34 @@ func NewGlobalConfigReader(cfg *viper.Viper, nm *netmapClient.Wrapper) *GlobalCo
}
func (c *GlobalConfig) BasicIncomeRate() (uint64, error) {
if isDebug() {
value := c.cfg.GetUint64("settlement.basic_income_rate")
if value != 0 {
return value, nil
}
}
return c.nm.BasicIncomeRate()
}
func (c *GlobalConfig) AuditFee() (uint64, error) {
if isDebug() {
value := c.cfg.GetUint64("settlement.audit_fee")
if value != 0 {
return value, nil
}
}
return c.nm.AuditFee()
}
func (c *GlobalConfig) EpochDuration() (uint32, error) {
if isDebug() {
value := c.cfg.GetUint32("timers.epoch")
if value != 0 {
return value, nil
}
}
epochDuration, err := c.nm.EpochDuration()
if err != nil {
@ -60,3 +67,7 @@ func (c *GlobalConfig) EpochDuration() (uint32, error) {
return uint32(epochDuration), nil
}
func isDebug() bool {
return misc.Debug == "true"
}