From 35ec694b049850615856aeddd1eb0257a626cc32 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 21 Apr 2021 08:29:35 +0300 Subject: [PATCH] [#488] cmd/cfg: Update `cfgReputation` Add `alpha` and `workerPool` to `cfgReputation` structure. Signed-off-by: Pavel Karpy --- cmd/neofs-node/config.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index f03568e9..c57bad4a 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -100,6 +100,11 @@ const ( cfgContainerWorkerPoolEnabled = "container.async_worker.enabled" cfgContainerWorkerPoolSize = "container.async_worker.size" + // config keys for cfgReputation + cfgReputationAlpha = "reputation.alpha" + cfgReputationWorkerPoolEnabled = "reputation.async_worker.enabled" + cfgReputationWorkerPoolSize = "reputation.async_worker.size" + cfgGCQueueSize = "gc.queuesize" cfgGCQueueTick = "gc.duration.sleep" cfgGCTimeout = "gc.duration.timeout" @@ -314,6 +319,11 @@ type cfgControlService struct { } type cfgReputation struct { + // Alpha parameter from origin EigenTrust algorithm + // http://ilpubs.stanford.edu:8090/562/1/2002-56.pdf Ch.5.1. + alpha float64 + workerPool util2.WorkerPool // pool for EigenTrust algorithm's iterations + localTrustStorage *truststorage.Storage localTrustCtrl *trustcontroller.Controller @@ -361,6 +371,9 @@ func initCfg(path string) *cfg { netmapWorkerPool, err := initNetmapWorkerPool(viperCfg) fatalOnErr(err) + reputationWorkerPool, err := initReputationWorkerPool(viperCfg) + fatalOnErr(err) + relayOnly := viperCfg.GetBool(cfgReBootstrapRelay) c := &cfg{ @@ -408,6 +421,10 @@ func initCfg(path string) *cfg { }, netStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)), healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)), + cfgReputation: cfgReputation{ + alpha: viper.GetFloat64(cfgReputationAlpha), + workerPool: reputationWorkerPool, + }, } if viperCfg.GetBool(cfgMetricsEnable) { @@ -461,6 +478,10 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgContainerWorkerPoolEnabled, true) v.SetDefault(cfgContainerWorkerPoolSize, 10) + v.SetDefault(cfgReputationAlpha, 0.5) + v.SetDefault(cfgReputationWorkerPoolEnabled, true) + v.SetDefault(cfgReputationWorkerPoolSize, 10) + v.SetDefault(cfgNetmapContract, "75194459637323ea8837d2afe8225ec74a5658c3") v.SetDefault(cfgNetmapFee, "1") v.SetDefault(cfgNetmapWorkerPoolEnabled, true) @@ -782,6 +803,16 @@ func initContainerWorkerPool(v *viper.Viper) (util2.WorkerPool, error) { return util2.SyncWorkerPool{}, nil } +func initReputationWorkerPool(v *viper.Viper) (util2.WorkerPool, error) { + if v.GetBool(cfgReputationWorkerPoolEnabled) { + // return async worker pool + return ants.NewPool(v.GetInt(cfgReputationWorkerPoolSize)) + } + + // return sync worker pool + return util2.SyncWorkerPool{}, nil +} + func (c *cfg) LocalNodeInfo() (*netmapV2.NodeInfo, error) { ni := c.localNodeInfo() return ni.ToV2(), nil