From 161fca58eb5fa30c8300b0a1f07e51247a47287f Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 1 Jun 2021 15:54:55 +0300 Subject: [PATCH] [#493] cmd/node: Use new config for contracts configuration Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 43 +++++----------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index bd66a4352..b84e47b1b 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -16,6 +16,7 @@ import ( netmapV2 "github.com/nspcc-dev/neofs-api-go/v2/netmap" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + contractsconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/contracts" engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine" shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard" grpcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/grpc" @@ -66,18 +67,6 @@ const ( cfgMainChainRPCAddress = "mainchain.rpc_endpoint" cfgMainChainDialTimeout = "mainchain.dial_timeout" - // config keys for cfgAccounting - cfgAccountingContract = "accounting.scripthash" - - // config keys for cfgNetmap - cfgNetmapContract = "netmap.scripthash" - - // config keys for cfgContainer - cfgContainerContract = "container.scripthash" - - // config keys for cfgReputation - cfgReputationContract = "reputation.scripthash" - cfgPolicerHeadTimeout = "policer.head_timeout" cfgReplicatorPutTimeout = "replicator.put_timeout" @@ -266,22 +255,6 @@ func initCfg(path string) *cfg { key, err := crypto.LoadPrivateKey(nodeconfig.Key(appCfg)) fatalOnErr(err) - u160Accounting, err := util.Uint160DecodeStringLE( - viperCfg.GetString(cfgAccountingContract)) - fatalOnErr(err) - - u160Netmap, err := util.Uint160DecodeStringLE( - viperCfg.GetString(cfgNetmapContract)) - fatalOnErr(err) - - u160Container, err := util.Uint160DecodeStringLE( - viperCfg.GetString(cfgContainerContract)) - fatalOnErr(err) - - u160Reputation, err := util.Uint160DecodeStringLE( - viperCfg.GetString(cfgReputationContract)) - fatalOnErr(err) - var logPrm logger.Prm err = logPrm.SetLevelString( @@ -338,14 +311,14 @@ func initCfg(path string) *cfg { key: key, apiVersion: pkg.SDKVersion(), cfgAccounting: cfgAccounting{ - scriptHash: u160Accounting, + scriptHash: contractsconfig.Balance(appCfg), }, cfgContainer: cfgContainer{ - scriptHash: u160Container, + scriptHash: contractsconfig.Container(appCfg), workerPool: containerWorkerPool, }, cfgNetmap: cfgNetmap{ - scriptHash: u160Netmap, + scriptHash: contractsconfig.Netmap(appCfg), state: state, workerPool: netmapWorkerPool, reBootstrapEnabled: !relayOnly, @@ -372,7 +345,7 @@ func initCfg(path string) *cfg { netStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)), healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)), cfgReputation: cfgReputation{ - scriptHash: u160Reputation, + scriptHash: contractsconfig.Reputation(appCfg), workerPool: reputationWorkerPool, }, } @@ -411,12 +384,6 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgAPIClientDialTimeout, 5*time.Second) - v.SetDefault(cfgAccountingContract, "") - - v.SetDefault(cfgContainerContract, "") - - v.SetDefault(cfgNetmapContract, "") - v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second) v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second)