[#488] storage/calculator: Make alpha dynamic

Delete reading `alpha` from env var. Cover
retrieving `alpha` behind interface in
intermediate calculator. Add TODO to decide
if it is necessary to receive that param from
global config or not.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-04-29 09:03:24 +03:00 committed by Alex Vanin
parent ad4a55468e
commit 2c8c9f69c8
6 changed files with 34 additions and 14 deletions

View file

@ -102,7 +102,6 @@ const (
// config keys for cfgReputation
cfgReputationContract = "reputation.scripthash"
cfgReputationAlpha = "reputation.alpha"
cfgReputationWorkerPoolEnabled = "reputation.async_worker.enabled"
cfgReputationWorkerPoolSize = "reputation.async_worker.size"
@ -320,9 +319,6 @@ 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
@ -430,7 +426,6 @@ func initCfg(path string) *cfg {
healthStatus: atomic.NewInt32(int32(control.HealthStatus_HEALTH_STATUS_UNDEFINED)),
cfgReputation: cfgReputation{
scriptHash: u160Reputation,
alpha: viper.GetFloat64(cfgReputationAlpha),
workerPool: reputationWorkerPool,
},
}
@ -486,7 +481,6 @@ 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)