frostfs-node/pkg/services/reputation/eigentrust/calculator/deps.go
Dmitrii Stepanov 7ebbfa3358 [#212] reputationsvc: Resolve linters and rename
Resolved containedctx linters.
Renamed context structs and interfaces to more understandble names.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2023-04-07 15:35:57 +00:00

74 lines
2.7 KiB
Go

package eigentrustcalc
import (
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/reputation/eigentrust"
apireputation "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/reputation"
)
type EpochIterationInfo interface {
// Must return epoch number to select the values
// for global trust calculation.
Epoch() uint64
// Must return the sequence number of the iteration.
I() uint32
}
// InitialTrustSource must provide initial(non-calculated)
// trusts to current node's daughter. Realization may depends
// on daughter.
type InitialTrustSource interface {
InitialTrust(apireputation.PeerID) (reputation.TrustValue, error)
}
// TrustIterator must iterate over all retrieved(or calculated) trusts
// and call passed TrustHandler on them.
type TrustIterator interface {
Iterate(reputation.TrustHandler) error
}
type PeerTrustsHandler func(apireputation.PeerID, TrustIterator) error
// PeerTrustsIterator must iterate over all nodes(PeerIDs) and provide
// TrustIterator for iteration over node's Trusts to others peers.
type PeerTrustsIterator interface {
Iterate(PeerTrustsHandler) error
}
type DaughterTrustIteratorProvider interface {
// InitDaughterIterator must init TrustIterator
// that iterates over received local trusts from
// daughter p for epochInfo.Epoch() epoch.
InitDaughterIterator(epochInfo EpochIterationInfo, p apireputation.PeerID) (TrustIterator, error)
// InitAllDaughtersIterator must init PeerTrustsIterator
// that must iterate over all daughters of the current
// node(manager) and all trusts received from them for
// epochInfo.Epoch() epoch.
InitAllDaughtersIterator(epochInfo EpochIterationInfo) (PeerTrustsIterator, error)
// InitConsumersIterator must init PeerTrustsIterator
// that must iterate over all daughters of the current
// node(manager) and their consumers' trusts received
// from other managers for epochInfo.Epoch() epoch and
// epochInfo.I() iteration.
InitConsumersIterator(EpochIterationInfo) (PeerTrustsIterator, error)
}
// IntermediateWriter must write intermediate result to contract.
// It may depends on realization either trust is sent directly to contract
// or via redirecting to other node.
type IntermediateWriter interface {
WriteIntermediateTrust(eigentrust.IterationTrust) error
}
// IntermediateWriterProvider must provide ready-to-work
// IntermediateWriter.
type IntermediateWriterProvider interface {
InitIntermediateWriter(EpochIterationInfo) (IntermediateWriter, error)
}
// AlphaProvider must provide information about required
// alpha parameter for eigen trust algorithm.
type AlphaProvider interface {
EigenTrustAlpha() (float64, error)
}