truststorage

package
v0.34.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPositiveTrust = errors.New("no positive trust")

ErrNoPositiveTrust is returned by iterator when there is no positive number of successful transactions.

Functions

This section is empty.

Types

type EpochTrustValueStorage

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

EpochTrustValueStorage represents storage of the trust values by particular epoch.

func (*EpochTrustValueStorage) Iterate

Iterate iterates over normalized trust values and passes them to parameterized handler.

Values are normalized according to http://ilpubs.stanford.edu:8090/562/1/2002-56.pdf Chapter 4.5. If divisor in formula is zero, ErrNoPositiveTrust returns.

type Prm

type Prm struct{}

Prm groups the required parameters of the Storage'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 Storage

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

Storage represents in-memory storage of local reputation values.

Storage provides access to normalized local trust values through iterator interface.

For correct operation, Storage must be created using the constructor (New) based on the required parameters and optional components. After successful creation, Storage is immediately ready to work through API.

func New

func New(prm Prm) *Storage

New creates a new instance of the Storage.

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

func (*Storage) DataForEpoch

func (s *Storage) DataForEpoch(epoch uint64) (*EpochTrustValueStorage, error)

DataForEpoch returns EpochValueStorage for epoch.

If there is no data for the epoch, ErrNoPositiveTrust returns.

func (*Storage) Update

func (s *Storage) Update(prm UpdatePrm)

Update updates the number of satisfactory transactions with peer.

type UpdatePrm

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

UpdatePrm groups the parameters of Storage's Update operation.

func (*UpdatePrm) SetEpoch

func (p *UpdatePrm) SetEpoch(e uint64)

SetEpoch sets number of the epoch when the interaction happened.

func (*UpdatePrm) SetPeer

func (p *UpdatePrm) SetPeer(id apireputation.PeerID)

SetPeer sets identifier of the peer with which the local node interacted.

func (*UpdatePrm) SetSatisfactory

func (p *UpdatePrm) SetSatisfactory(sat bool)

SetSatisfactory sets successful completion status.

Jump to

Keyboard shortcuts

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