2021-04-10 12:02:51 +00:00
|
|
|
package eigentrustcalc
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"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"
|
2021-04-10 12:02:51 +00:00
|
|
|
)
|
|
|
|
|
2023-04-05 07:44:40 +00:00
|
|
|
type EpochIterationInfo interface {
|
2021-04-10 12:02:51 +00:00
|
|
|
// Must return epoch number to select the values
|
|
|
|
// for global trust calculation.
|
|
|
|
Epoch() uint64
|
|
|
|
|
|
|
|
// Must return the sequence number of the iteration.
|
|
|
|
I() uint32
|
|
|
|
}
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// InitialTrustSource must provide initial(non-calculated)
|
|
|
|
// trusts to current node's daughter. Realization may depends
|
|
|
|
// on daughter.
|
2021-04-10 12:02:51 +00:00
|
|
|
type InitialTrustSource interface {
|
2022-07-04 13:24:51 +00:00
|
|
|
InitialTrust(apireputation.PeerID) (reputation.TrustValue, error)
|
2021-04-10 12:02:51 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// TrustIterator must iterate over all retrieved(or calculated) trusts
|
|
|
|
// and call passed TrustHandler on them.
|
2021-04-10 12:02:51 +00:00
|
|
|
type TrustIterator interface {
|
|
|
|
Iterate(reputation.TrustHandler) error
|
|
|
|
}
|
|
|
|
|
2022-07-04 13:24:51 +00:00
|
|
|
type PeerTrustsHandler func(apireputation.PeerID, TrustIterator) error
|
2021-04-10 12:02:51 +00:00
|
|
|
|
2021-04-29 05:30:41 +00:00
|
|
|
// PeerTrustsIterator must iterate over all nodes(PeerIDs) and provide
|
|
|
|
// TrustIterator for iteration over node's Trusts to others peers.
|
2021-04-10 12:02:51 +00:00
|
|
|
type PeerTrustsIterator interface {
|
|
|
|
Iterate(PeerTrustsHandler) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type DaughterTrustIteratorProvider interface {
|
2021-04-29 05:30:41 +00:00
|
|
|
// InitDaughterIterator must init TrustIterator
|
|
|
|
// that iterates over received local trusts from
|
2023-04-05 07:44:40 +00:00
|
|
|
// daughter p for epochInfo.Epoch() epoch.
|
|
|
|
InitDaughterIterator(epochInfo EpochIterationInfo, p apireputation.PeerID) (TrustIterator, error)
|
2021-04-29 05:30:41 +00:00
|
|
|
// InitAllDaughtersIterator must init PeerTrustsIterator
|
|
|
|
// that must iterate over all daughters of the current
|
|
|
|
// node(manager) and all trusts received from them for
|
2023-04-05 07:44:40 +00:00
|
|
|
// epochInfo.Epoch() epoch.
|
|
|
|
InitAllDaughtersIterator(epochInfo EpochIterationInfo) (PeerTrustsIterator, error)
|
2021-04-29 05:30:41 +00:00
|
|
|
// InitConsumersIterator must init PeerTrustsIterator
|
|
|
|
// that must iterate over all daughters of the current
|
|
|
|
// node(manager) and their consumers' trusts received
|
2023-04-05 07:44:40 +00:00
|
|
|
// from other managers for epochInfo.Epoch() epoch and
|
|
|
|
// epochInfo.I() iteration.
|
|
|
|
InitConsumersIterator(EpochIterationInfo) (PeerTrustsIterator, error)
|
2021-04-10 12:02:51 +00:00
|
|
|
}
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// 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.
|
2021-04-10 12:02:51 +00:00
|
|
|
type IntermediateWriter interface {
|
|
|
|
WriteIntermediateTrust(eigentrust.IterationTrust) error
|
|
|
|
}
|
|
|
|
|
2021-04-29 06:33:09 +00:00
|
|
|
// IntermediateWriterProvider must provide ready-to-work
|
|
|
|
// IntermediateWriter.
|
2021-04-10 12:02:51 +00:00
|
|
|
type IntermediateWriterProvider interface {
|
2023-04-05 07:44:40 +00:00
|
|
|
InitIntermediateWriter(EpochIterationInfo) (IntermediateWriter, error)
|
2021-04-10 12:02:51 +00:00
|
|
|
}
|
2021-04-29 06:03:24 +00:00
|
|
|
|
|
|
|
// AlphaProvider must provide information about required
|
|
|
|
// alpha parameter for eigen trust algorithm.
|
|
|
|
type AlphaProvider interface {
|
|
|
|
EigenTrustAlpha() (float64, error)
|
|
|
|
}
|