trustcontroller

package
v0.0.0-...-0ba0ddf Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleWriterProvider

func SimpleWriterProvider(w common.Writer) common.WriterProvider

SimpleWriterProvider returns WriterProvider that provides static context-independent Writer.

Types

type Controller

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

Controller represents main handler for starting and interrupting the reporting local trust values.

It binds the interfaces of the local value stores to the target storage points. Controller is abstracted from the internal storage device and the network location of the connecting components. At its core, it is a high-level start-stop trigger for reporting.

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) Report

func (c *Controller) Report(prm ReportPrm)

Report reports local reputation values.

Single Report operation overtakes all data from LocalTrustSource to LocalTrustTarget (Controller's parameters).

Each call acquires a report context for an Epoch parameter. At the very end of the operation, the context is released.

func (*Controller) Stop

func (c *Controller) Stop(prm StopPrm)

Stop interrupts the processing of local trust values.

Releases acquired report context.

type Iterator

type Iterator interface {
	// Iterate must start an iterator over all trust values.
	// For each value should call a handler, the error
	// of which should be directly returned from the method.
	//
	// Internal failures of the iterator are also signaled via
	// an error. After a successful call to the last value
	// handler, nil should be returned.
	Iterate(reputation.TrustHandler) error
}

Iterator is a group of methods provided by entity which can iterate over a group of reputation.Trust values.

type IteratorProvider

type IteratorProvider interface {
	// InitIterator should return an initialized Iterator
	// that iterates over values from IteratorContext.Epoch() epoch.
	//
	// Initialization problems are reported via error.
	// If no error was returned, then the Iterator must not be nil.
	//
	// Implementations can have different logic for different
	// contexts, so specific ones may document their own behavior.
	InitIterator(common.Context) (Iterator, error)
}

IteratorProvider is a group of methods provided by entity which generates iterators over reputation.Trust values.

func SimpleIteratorProvider

func SimpleIteratorProvider(i Iterator) IteratorProvider

SimpleIteratorProvider returns IteratorProvider that provides static context-independent Iterator.

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 {
	// Iterator over the reputation values
	// collected by the node locally.
	//
	// Must not be nil.
	LocalTrustSource IteratorProvider

	// Place of recording the local values of
	// trust to other nodes.
	//
	// Must not be nil.
	LocalTrustTarget reputationcommon.WriterProvider
}

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).

type ReportPrm

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

ReportPrm groups the required parameters of the Controller.Report method.

func (*ReportPrm) SetEpoch

func (p *ReportPrm) SetEpoch(e uint64)

SetEpoch sets epoch number to select reputation values.

type StopPrm

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

StopPrm groups the required parameters of the Controller.Stop method.

func (*StopPrm) SetEpoch

func (p *StopPrm) SetEpoch(e uint64)

SetEpoch sets epoch number the processing of the values of which must be interrupted.

Jump to

Keyboard shortcuts

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