reputation

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TrustOne is a trust value equal to one.
	TrustOne = TrustValue(1)

	// TrustZero is a trust value equal to zero.
	TrustZero = TrustValue(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerID

type PeerID [peerIDLength]byte

PeerID represents identifier of reputation system participant.

func PeerIDFromBytes

func PeerIDFromBytes(data []byte) (id PeerID)

PeerIDFromBytes restores PeerID from []byte.

func (PeerID) Bytes

func (id PeerID) Bytes() []byte

Bytes converts PeerID to []byte.

type Trust

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

Trust represents peer's trust (reputation).

func (Trust) Peer

func (t Trust) Peer() PeerID

Peer returns trusted peer ID.

func (*Trust) SetPeer

func (t *Trust) SetPeer(id PeerID)

SetPeer sets trusted peer ID.

func (*Trust) SetTrustingPeer added in v0.19.0

func (t *Trust) SetTrustingPeer(id PeerID)

SetTrustingPeer sets trusting peer ID.

func (*Trust) SetValue

func (t *Trust) SetValue(val TrustValue)

SetValue sets peer's trust value.

func (Trust) TrustingPeer added in v0.19.0

func (t Trust) TrustingPeer() PeerID

TrustingPeer returns trusting peer ID.

func (Trust) Value

func (t Trust) Value() TrustValue

Value returns peer's trust value.

type TrustHandler

type TrustHandler func(Trust) error

TrustHandler describes the signature of the reputation.Trust value handling function.

Termination of processing without failures is usually signaled with a zero error, while a specific value may describe the reason for failure.

type TrustValue

type TrustValue float64

TrustValue represents the numeric value of the node's trust.

func TrustValueFromFloat64

func TrustValueFromFloat64(v float64) TrustValue

TrustValueFromFloat64 converts float64 to TrustValue.

func TrustValueFromInt

func TrustValueFromInt(v int) TrustValue

TrustValueFromInt converts int to TrustValue.

func (*TrustValue) Add

func (v *TrustValue) Add(v2 TrustValue)

Add adds v2 to v.

func (TrustValue) Div

func (v TrustValue) Div(v2 TrustValue) TrustValue

Div returns the result of dividing v by v2.

func (TrustValue) Float64

func (v TrustValue) Float64() float64

Float64 converts TrustValue to float64.

func (TrustValue) IsZero

func (v TrustValue) IsZero() bool

IsZero returns true if v equal to zero.

func (*TrustValue) Mul added in v0.19.0

func (v *TrustValue) Mul(v2 TrustValue)

Mul multiplies v by v2.

func (TrustValue) String

func (v TrustValue) String() string

Jump to

Keyboard shortcuts

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