trust

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2017 License: Apache-2.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 MetricHistoryJSON

type MetricHistoryJSON struct {
	NumIntervals int       `json:"intervals"`
	History      []float64 `json:"history"`
}

MetricHistoryJSON - history data necessary to save the trust metric

type TrustMetric

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

TrustMetric - keeps track of peer reliability See tendermint/docs/architecture/adr-006-trust-metric.md for details

func NewMetric

func NewMetric() *TrustMetric

NewMetric returns a trust metric with the default configuration

func NewMetricWithConfig

func NewMetricWithConfig(tmc TrustMetricConfig) *TrustMetric

NewMetricWithConfig returns a trust metric with a custom configuration

func (*TrustMetric) BadEvents

func (tm *TrustMetric) BadEvents(num int)

BadEvents indicates that an undesirable event(s) took place

func (*TrustMetric) Copy

func (tm *TrustMetric) Copy() *TrustMetric

Copy returns a new trust metric with members containing the same values

func (*TrustMetric) GoodEvents

func (tm *TrustMetric) GoodEvents(num int)

GoodEvents indicates that a desirable event(s) took place

func (*TrustMetric) HistoryJSON

func (tm *TrustMetric) HistoryJSON() MetricHistoryJSON

Returns a snapshot of the trust metric history data

func (*TrustMetric) Init

func (tm *TrustMetric) Init(hist MetricHistoryJSON)

Instantiates a trust metric by loading the history data for a single peer. This is called only once and only right after creation, which is why the lock is not held while accessing the trust metric struct members

func (*TrustMetric) NextTimeInterval

func (tm *TrustMetric) NextTimeInterval()

NextTimeInterval saves current time interval data and prepares for the following interval

func (*TrustMetric) Pause

func (tm *TrustMetric) Pause()

Pause tells the metric to pause recording data over time intervals. All method calls that indicate events will unpause the metric

func (*TrustMetric) Stop added in v0.13.0

func (tm *TrustMetric) Stop()

Stop tells the metric to stop recording data over time intervals

func (*TrustMetric) TrustScore

func (tm *TrustMetric) TrustScore() int

TrustScore gets a score based on the trust value always between 0 and 100

func (*TrustMetric) TrustValue

func (tm *TrustMetric) TrustValue() float64

TrustValue gets the dependable trust value; always between 0 and 1

type TrustMetricConfig

type TrustMetricConfig struct {
	// Determines the percentage given to current behavior
	ProportionalWeight float64

	// Determines the percentage given to prior behavior
	IntegralWeight float64

	// The window of time that the trust metric will track events across.
	// This can be set to cover many days without issue
	TrackingWindow time.Duration

	// Each interval should be short for adapability.
	// Less than 30 seconds is too sensitive,
	// and greater than 5 minutes will make the metric numb
	IntervalLength time.Duration
}

TrustMetricConfig - Configures the weight functions and time intervals for the metric

func DefaultConfig

func DefaultConfig() TrustMetricConfig

DefaultConfig returns a config with values that have been tested and produce desirable results

type TrustMetricStore

type TrustMetricStore struct {
	cmn.BaseService
	// contains filtered or unexported fields
}

TrustMetricStore - Manages all trust metrics for peers

func NewTrustMetricStore

func NewTrustMetricStore(db dbm.DB, tmc TrustMetricConfig) *TrustMetricStore

NewTrustMetricStore returns a store that saves data to the DB and uses the config when creating new trust metrics

func (*TrustMetricStore) GetPeerTrustMetric

func (tms *TrustMetricStore) GetPeerTrustMetric(key string) *TrustMetric

GetPeerTrustMetric returns a trust metric by peer key

func (*TrustMetricStore) OnStart

func (tms *TrustMetricStore) OnStart() error

OnStart implements Service

func (*TrustMetricStore) OnStop

func (tms *TrustMetricStore) OnStop()

OnStop implements Service

func (*TrustMetricStore) PeerDisconnected

func (tms *TrustMetricStore) PeerDisconnected(key string)

PeerDisconnected pauses the trust metric associated with the peer identified by the key

func (*TrustMetricStore) SaveToDB

func (tms *TrustMetricStore) SaveToDB()

Saves the history data for all peers to the store DB. This public method acquires the trust metric store lock

func (*TrustMetricStore) Size

func (tms *TrustMetricStore) Size() int

Size returns the number of entries in the trust metric store

Jump to

Keyboard shortcuts

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