diff --git a/Makefile b/Makefile index bef55b13..644a6156 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ SHELL = bash REPO ?= $(shell go list -m) VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") -DEBUG ?= false HUB_IMAGE ?= nspccdev/neofs HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" @@ -34,8 +33,7 @@ $(BINS): $(DIRS) dep @echo "⇒ Build $@" CGO_ENABLED=0 \ go build -v -trimpath \ - -ldflags "-X $(REPO)/misc.Version=$(VERSION) \ - -X $(REPO)/misc.Debug=$(DEBUG)" \ + -ldflags "-X $(REPO)/misc.Version=$(VERSION)" \ -o $@ ./cmd/$(notdir $@) $(DIRS): diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index 824bef41..bc79049c 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -80,9 +80,7 @@ func main() { exitErr(err) log.Info("application started", - zap.String("version", misc.Version), - zap.String("debug", misc.Debug), - ) + zap.String("version", misc.Version)) select { case <-ctx.Done(): diff --git a/cmd/neofs-node/config/util.go b/cmd/neofs-node/config/util.go deleted file mode 100644 index 07b43902..00000000 --- a/cmd/neofs-node/config/util.go +++ /dev/null @@ -1,16 +0,0 @@ -package config - -import ( - "github.com/nspcc-dev/neofs-node/misc" -) - -// DebugValue returns debug configuration value. -// -// Returns nil if misc.Debug is not set to "true". -func DebugValue(c *Config, name string) interface{} { - if misc.Debug == "true" { - return c.Value(name) - } - - return nil -} diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index 74440ea6..64f54498 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -110,9 +110,7 @@ func bootUp(c *cfg) { func wait(c *cfg) { c.log.Info("application started", - zap.String("version", misc.Version), - zap.String("debug", misc.Debug), - ) + zap.String("version", misc.Version)) select { case <-c.ctx.Done(): // graceful shutdown diff --git a/misc/build.go b/misc/build.go index 710229df..52d9e13c 100644 --- a/misc/build.go +++ b/misc/build.go @@ -9,17 +9,13 @@ import ( var ( // Version is an application version. Version = "dev" - - // Debug is an application debug mode flag. - Debug = "false" ) // BuildInfo returns human-readable information about this binary. func BuildInfo(component string) string { - return fmt.Sprintf("%s\nVersion: %s \nGoVersion: %s\nDebug: %s\n", + return fmt.Sprintf("%s\nVersion: %s \nGoVersion: %s\n", component, Version, runtime.Version(), - Debug, ) } diff --git a/pkg/innerring/config/config.go b/pkg/innerring/config/config.go deleted file mode 100644 index 5cb74aff..00000000 --- a/pkg/innerring/config/config.go +++ /dev/null @@ -1,57 +0,0 @@ -package config - -/* -Config package contains GlobalConfig structure that implements config -reader from both local and global configurations. Most of the time the inner ring -does not need this; as for application, it has static config with timeouts, -caches sizes etc. However, there are routines that use global configuration -values that can be changed in runtime, e.g. basic income rate. Local -configuration value overrides the global one so it is easy to debug and test -in different environments. - -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" - "github.com/spf13/viper" -) - -type GlobalConfig struct { - cfg *viper.Viper - nm *netmapClient.Client -} - -func NewGlobalConfigReader(cfg *viper.Viper, nm *netmapClient.Client) *GlobalConfig { - return &GlobalConfig{ - cfg: cfg, - nm: nm, - } -} - -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 isDebug() bool { - return misc.Debug == "true" -} diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index d4ab96f3..85ff3d5b 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -550,9 +550,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- cfg.GetDuration("indexer.cache_timeout"), ) - // create global runtime config reader - globalConfig := config.NewGlobalConfigReader(cfg, server.netmapClient) - clientCache := newClientCache(&clientCacheParams{ Log: log, Key: &server.key.PrivateKey, @@ -602,11 +599,10 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- // create settlement processor dependencies settlementDeps := settlementDeps{ - globalConfig: globalConfig, log: server.log, cnrSrc: cntClient.AsContainerSource(cnrClient), auditClient: server.auditClient, - nmSrc: server.netmapClient, + nmClient: server.netmapClient, clientCache: clientCache, balanceClient: server.balanceClient, } @@ -630,7 +626,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper, errChan chan<- SGStorage: auditCalcDeps, AccountStorage: auditCalcDeps, Exchanger: auditCalcDeps, - AuditFeeFetcher: auditCalcDeps, + AuditFeeFetcher: server.netmapClient, }, auditSettlement.WithLogger(server.log), ) diff --git a/pkg/innerring/settlement.go b/pkg/innerring/settlement.go index 8555fcb2..1f8da39c 100644 --- a/pkg/innerring/settlement.go +++ b/pkg/innerring/settlement.go @@ -18,6 +18,7 @@ import ( auditClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/audit" balanceClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/balance" containerClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/container" + netmapClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" "github.com/nspcc-dev/neofs-node/pkg/util/logger" auditAPI "github.com/nspcc-dev/neofs-sdk-go/audit" containerAPI "github.com/nspcc-dev/neofs-sdk-go/container" @@ -29,26 +30,19 @@ import ( "go.uber.org/zap" ) -type globalConfig interface { - BasicIncomeRate() (uint64, error) - AuditFee() (uint64, error) -} - const ( auditSettlementContext = "audit" basicIncomeSettlementContext = "basic income" ) type settlementDeps struct { - globalConfig - log *logger.Logger cnrSrc container.Source auditClient *auditClient.Client - nmSrc netmap.Source + nmClient *netmapClient.Client clientCache *ClientCache @@ -132,9 +126,9 @@ func (s settlementDeps) buildContainer(e uint64, cid cid.ID) ([][]netmapAPI.Node ) if e > 0 { - nm, err = s.nmSrc.GetNetMapByEpoch(e) + nm, err = s.nmClient.GetNetMapByEpoch(e) } else { - nm, err = netmap.GetLatestNetworkMap(s.nmSrc) + nm, err = netmap.GetLatestNetworkMap(s.nmClient) } if err != nil { @@ -254,7 +248,7 @@ func (s settlementDeps) Transfer(sender, recipient user.ID, amount *big.Int, det } func (b basicIncomeSettlementDeps) BasicRate() (uint64, error) { - return b.BasicIncomeRate() + return b.nmClient.BasicIncomeRate() } func (b basicIncomeSettlementDeps) Estimations(epoch uint64) ([]*containerClient.Estimations, error) {