eigentrustctrl

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContinuePrm

type ContinuePrm struct {
	Epoch uint64
}

ContinuePrm groups the required parameters of Continue operation.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller represents EigenTrust algorithm transient controller.

Controller's main goal is to separate the two main stages of the calculation:

  1. reporting local values to manager nodes
  2. calculating global trusts of child nodes

Calculation stages are controlled based on external signals that come from the application through the Controller's API.

For correct operation, the controller must be created using the constructor (New) based on the required parameters and optional components. After successful creation, the constructor is immediately ready to work through API of external control of calculations and data transfer.

func New

func New(prm Prm, opts ...Option) *Controller

New creates a new instance of the Controller.

Panics if at least one value of the parameters is invalid.

The created Controller does not require additional initialization and is completely ready for work.

func (*Controller) Continue

func (c *Controller) Continue(prm ContinuePrm)

Continue moves the global reputation calculator to the next iteration.

type DaughtersTrustCalculator

type DaughtersTrustCalculator interface {
	// Must perform the iteration step of the loop
	// for computing the global trust of all daughter
	// nodes and sending intermediate values
	// according to EigenTrust description
	// http://ilpubs.stanford.edu:8090/562/1/2002-56.pdf Ch.5.1.
	//
	// Execution should be interrupted if ctx.Last().
	Calculate(ctx IterationContext)
}

DaughtersTrustCalculator is an interface of entity responsible for calculating the global trust of daughter nodes in terms of EigenTrust algorithm.

type IterationContext

type IterationContext 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

	// Must return true if I() is the last iteration.
	Last() bool
}

IterationContext is a context of the i-th stage of iterative EigenTrust algorithm.

type IterationsProvider

type IterationsProvider interface {
	EigenTrustIterations() (uint64, error)
}

IterationsProvider must provide information about numbers of iterations for algorithm.

type Option

type Option func(*options)

Option sets an optional parameter of Controller.

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger returns option to specify logging component.

Ignores nil values.

type Prm

type Prm struct {
	// Component of computing iteration of EigenTrust algorithm.
	//
	// Must not be nil.
	DaughtersTrustCalculator DaughtersTrustCalculator

	// IterationsProvider provides information about numbers
	// of iterations for algorithm.
	IterationsProvider IterationsProvider

	// Routine execution pool for single epoch iteration.
	WorkerPool util.WorkerPool
}

Prm groups the required parameters of the Controller'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).

Jump to

Keyboard shortcuts

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