eigentrustcalc

package
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlphaProvider

type AlphaProvider interface {
	EigenTrustAlpha() (float64, error)
}

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 Context

type Context interface {
	context.Context

	// Must return epoch number to select the values
	// for global trust calculation.
	Epoch() uint64

	// Must return the sequence number of the iteration.
	I() uint32
}

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 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
	// 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(apireputation.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.

func WithLogger

func WithLogger(l *logger.Logger) Option

WithLogger returns option to specify logging component.

Ignores nil values.

type PeerTrustsHandler

type PeerTrustsHandler func(apireputation.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL