Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlphaProvider ¶
AlphaProvider must provide information about required alpha parameter for eigen trust algorithm.
type CalculatePrm ¶
type CalculatePrm struct {
// contains filtered or unexported fields
}
func (*CalculatePrm) SetEpochIteration ¶
func (p *CalculatePrm) SetEpochIteration(ei eigentrust.EpochIteration)
func (*CalculatePrm) SetLast ¶
func (p *CalculatePrm) SetLast(last bool)
type Calculator ¶
type Calculator struct {
// contains filtered or unexported fields
}
Calculator is a processor of a single iteration of EigenTrust algorithm.
For correct operation, the Calculator must be created using the constructor (New) based on the required parameters and optional components. After successful creation, the Calculator is immediately ready to work through API of external control of calculations and data transfer.
func New ¶
func New(prm Prm, opts ...Option) *Calculator
New creates a new instance of the Calculator.
Panics if at least one value of the parameters is invalid.
The created Calculator does not require additional initialization and is completely ready for work.
func (*Calculator) Calculate ¶
func (c *Calculator) Calculate(prm CalculatePrm)
type DaughterTrustIteratorProvider ¶
type DaughterTrustIteratorProvider interface { // InitDaughterIterator must init TrustIterator // that iterates over received local trusts from // daughter p for ctx.Epoch() epoch. InitDaughterIterator(ctx Context, p reputation.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 // ctx.Epoch() epoch. InitAllDaughtersIterator(ctx Context) (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 ctx.Epoch() epoch and // ctx.I() iteration. InitConsumersIterator(Context) (PeerTrustsIterator, error) }
type InitialTrustSource ¶
type InitialTrustSource interface {
InitialTrust(reputation.PeerID) (reputation.TrustValue, error)
}
InitialTrustSource must provide initial(non-calculated) trusts to current node's daughter. Realization may depends on daughter.
type IntermediateWriter ¶
type IntermediateWriter interface {
WriteIntermediateTrust(eigentrust.IterationTrust) 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 IntermediateWriterProvider ¶
type IntermediateWriterProvider interface {
InitIntermediateWriter(Context) (IntermediateWriter, error)
}
IntermediateWriterProvider must provide ready-to-work IntermediateWriter.
type Option ¶
type Option func(*options)
Option sets an optional parameter of Controller.
type PeerTrustsHandler ¶
type PeerTrustsHandler func(reputation.PeerID, TrustIterator) error
type PeerTrustsIterator ¶
type PeerTrustsIterator interface {
Iterate(PeerTrustsHandler) error
}
PeerTrustsIterator must iterate over all nodes(PeerIDs) and provide TrustIterator for iteration over node's Trusts to others peers.
type Prm ¶
type Prm struct { // Alpha parameter from origin EigenTrust algorithm // http://ilpubs.stanford.edu:8090/562/1/2002-56.pdf Ch.5.1. // // Must be in range (0, 1). AlphaProvider AlphaProvider // Source of initial node trust values // // Must not be nil. InitialTrustSource InitialTrustSource DaughterTrustSource DaughterTrustIteratorProvider IntermediateValueTarget common.WriterProvider FinalResultTarget IntermediateWriterProvider WorkerPool util.WorkerPool }
Prm groups the required parameters of the Calculator's constructor.
All values must comply with the requirements imposed on them. Passing incorrect parameter values will result in constructor failure (error or panic depending on the implementation).
type TrustIterator ¶
type TrustIterator interface {
Iterate(reputation.TrustHandler) error
}
TrustIterator must iterate over all retrieved(or calculated) trusts and call passed TrustHandler on them.