forked from TrueCloudLab/frostfs-node
2c8c9f69c8
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>
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package intermediate
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust"
|
|
eigencalc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust/calculator"
|
|
eigentrustctrl "github.com/nspcc-dev/neofs-node/pkg/services/reputation/eigentrust/controller"
|
|
)
|
|
|
|
// DaughtersTrustCalculator wraps EigenTrust calculator and implements
|
|
// eigentrust/calculator's DaughtersTrustCalculator interface.
|
|
type DaughtersTrustCalculator struct {
|
|
Calculator *eigencalc.Calculator
|
|
}
|
|
|
|
// Calculate converts and passes values to wrapped calculator.
|
|
func (c *DaughtersTrustCalculator) Calculate(ctx eigentrustctrl.IterationContext) {
|
|
calcPrm := eigencalc.CalculatePrm{}
|
|
epochIteration := eigentrust.EpochIteration{}
|
|
|
|
epochIteration.SetEpoch(ctx.Epoch())
|
|
epochIteration.SetI(ctx.I())
|
|
|
|
calcPrm.SetLast(ctx.Last())
|
|
calcPrm.SetEpochIteration(epochIteration)
|
|
|
|
c.Calculator.Calculate(calcPrm)
|
|
}
|
|
|
|
// AlphaProvider provides required alpha parameter of eigen trust algorithm.
|
|
// TODO: decide if `Alpha` should be dynamically read from global config. #497
|
|
type AlphaProvider struct {
|
|
Alpha float64
|
|
}
|
|
|
|
func (ap AlphaProvider) EigenTrustAlpha() (float64, error) {
|
|
return ap.Alpha, nil
|
|
}
|