go-ethereum: github.com/ethereum/go-ethereum/les/lespay/client Index | Files

package client

import "github.com/ethereum/go-ethereum/les/lespay/client"

Index

Package Files

api.go fillset.go queueiterator.go requestbasket.go timestats.go valuetracker.go wrsiterator.go

func StatScaleToTime Uses

func StatScaleToTime(r float64) time.Duration

StatScaleToTime converts a distribution vector index to a response time. The index is represented by a float64 so that linear interpolation can be applied.

func TimeToStatScale Uses

func TimeToStatScale(d time.Duration) float64

TimeToStatScale converts a response time to a distribution vector index. The index is represented by a float64 so that linear interpolation can be applied.

type FillSet Uses

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

FillSet tries to read nodes from an input iterator and add them to a node set by setting the specified node state flag(s) until the size of the set reaches the target. Note that other mechanisms (like other FillSet instances reading from different inputs) can also set the same flag(s) and FillSet will always care about the total number of nodes having those flags.

func NewFillSet Uses

func NewFillSet(ns *nodestate.NodeStateMachine, input enode.Iterator, flags nodestate.Flags) *FillSet

NewFillSet creates a new FillSet

func (*FillSet) Close Uses

func (fs *FillSet) Close()

Close shuts FillSet down and closes the input iterator

func (*FillSet) SetTarget Uses

func (fs *FillSet) SetTarget(target int)

SetTarget sets the current target for node set size. If the previous target was not reached and FillSet was still waiting for the next node from the input then the next incoming node will be added to the set regardless of the target. This ensures that all nodes coming from the input are eventually added to the set.

type NodeValueTracker Uses

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

NodeValueTracker collects service value statistics for a specific server node

func (*NodeValueTracker) RtStats Uses

func (nv *NodeValueTracker) RtStats() ResponseTimeStats

RtStats returns the node's own response time distribution statistics

type PrivateClientAPI Uses

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

PrivateClientAPI implements the lespay client side API

func NewPrivateClientAPI Uses

func NewPrivateClientAPI(vt *ValueTracker) *PrivateClientAPI

NewPrivateClientAPI creates a PrivateClientAPI

func (*PrivateClientAPI) Distribution Uses

func (api *PrivateClientAPI) Distribution(nodeStr string, normalized bool) (RtDistribution, error)

Distribution returns a distribution as a series of (X, Y) chart coordinates, where the X axis is the response time in seconds while the Y axis is the amount of service value received with a response time close to the X coordinate. The distribution is optionally normalized to a sum of 1. If nodeStr == "" then the global distribution is returned, otherwise the individual distribution of the specified server node.

func (*PrivateClientAPI) RequestStats Uses

func (api *PrivateClientAPI) RequestStats() []RequestStatsItem

RequestStats returns the current contents of the reference request basket, with request values meaning average per request rather than total.

func (*PrivateClientAPI) Timeout Uses

func (api *PrivateClientAPI) Timeout(nodeStr string, failRate float64) (float64, error)

Timeout suggests a timeout value based on either the global distribution or the distribution of the specified node. The parameter is the desired rate of timeouts assuming a similar distribution in the future. Note that the actual timeout should have a sensible minimum bound so that operating under ideal working conditions for a long time (for example, using a local server with very low response times) will not make it very hard for the system to accommodate longer response times in the future.

func (*PrivateClientAPI) Value Uses

func (api *PrivateClientAPI) Value(nodeStr string, timeout float64) (float64, error)

Value calculates the total service value provided either globally or by the specified server node, using a weight function based on the given timeout.

type QueueIterator Uses

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

QueueIterator returns nodes from the specified selectable set in the same order as they entered the set.

func NewQueueIterator Uses

func NewQueueIterator(ns *nodestate.NodeStateMachine, requireFlags, disableFlags nodestate.Flags, fifo bool, waitCallback func(bool)) *QueueIterator

NewQueueIterator creates a new QueueIterator. Nodes are selectable if they have all the required and none of the disabled flags set. When a node is selected the selectedFlag is set which also disables further selectability until it is removed or times out.

func (*QueueIterator) Close Uses

func (qi *QueueIterator) Close()

Close ends the iterator.

func (*QueueIterator) Next Uses

func (qi *QueueIterator) Next() bool

Next moves to the next selectable node.

func (*QueueIterator) Node Uses

func (qi *QueueIterator) Node() *enode.Node

Node returns the current node.

type RequestInfo Uses

type RequestInfo struct {
    // Name identifies the request type and is used for re-mapping the service vector if necessary
    Name string
    // InitAmount and InitValue are used to initialize the reference basket
    InitAmount, InitValue float64
}

RequestInfo is an initializer structure for the service vector.

type RequestStatsItem Uses

type RequestStatsItem struct {
    Name                string
    ReqAmount, ReqValue float64
}

type ResponseTimeStats Uses

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

ResponseTimeStats is the response time distribution of a set of answered requests, weighted with request value, either served by a single server or aggregated for multiple servers. It it a fixed length (timeStatLength) distribution vector with linear interpolation. The X axis (the time values) are not linear, they should be transformed with TimeToStatScale and StatScaleToTime.

func (*ResponseTimeStats) Add Uses

func (rt *ResponseTimeStats) Add(respTime time.Duration, weight float64, expFactor utils.ExpirationFactor)

Add adds a new response time with the given weight to the distribution.

func (*ResponseTimeStats) AddStats Uses

func (rt *ResponseTimeStats) AddStats(s *ResponseTimeStats)

AddStats adds the given ResponseTimeStats to the current one.

func (*ResponseTimeStats) DecodeRLP Uses

func (rt *ResponseTimeStats) DecodeRLP(s *rlp.Stream) error

DecodeRLP implements rlp.Decoder

func (ResponseTimeStats) Distribution Uses

func (rt ResponseTimeStats) Distribution(normalized bool, expFactor utils.ExpirationFactor) (res RtDistribution)

Distribution returns a RtDistribution, optionally normalized to a sum of 1.

func (*ResponseTimeStats) EncodeRLP Uses

func (rt *ResponseTimeStats) EncodeRLP(w io.Writer) error

EncodeRLP implements rlp.Encoder

func (*ResponseTimeStats) SubStats Uses

func (rt *ResponseTimeStats) SubStats(s *ResponseTimeStats)

SubStats subtracts the given ResponseTimeStats from the current one.

func (ResponseTimeStats) Timeout Uses

func (rt ResponseTimeStats) Timeout(failRatio float64) time.Duration

Timeout suggests a timeout value based on the previous distribution. The parameter is the desired rate of timeouts assuming a similar distribution in the future. Note that the actual timeout should have a sensible minimum bound so that operating under ideal working conditions for a long time (for example, using a local server with very low response times) will not make it very hard for the system to accommodate longer response times in the future.

func (ResponseTimeStats) Value Uses

func (rt ResponseTimeStats) Value(weights ResponseTimeWeights, expFactor utils.ExpirationFactor) float64

Value calculates the total service value based on the given distribution, using the specified weight function.

type ResponseTimeWeights Uses

type ResponseTimeWeights [timeStatLength]float64

ResponseTimeStats is the response time distribution of a set of answered requests, weighted with request value, either served by a single server or aggregated for multiple servers. It it a fixed length (timeStatLength) distribution vector with linear interpolation. The X axis (the time values) are not linear, they should be transformed with TimeToStatScale and StatScaleToTime.

func TimeoutWeights Uses

func TimeoutWeights(timeout time.Duration) (res ResponseTimeWeights)

TimeoutWeights calculates the weight function used for calculating service value based on the response time distribution of the received service. It is based on the request timeout value of the system. It consists of a half cosine function starting with 1, crossing zero at timeout and reaching -1 at 2*timeout. After 2*timeout the weight is constant -1.

type RtDistribution Uses

type RtDistribution [timeStatLength][2]float64

RtDistribution represents a distribution as a series of (X, Y) chart coordinates, where the X axis is the response time in seconds while the Y axis is the amount of service value received with a response time close to the X coordinate.

type ServedRequest Uses

type ServedRequest struct {
    ReqType, Amount uint32
}

type ValueTracker Uses

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

ValueTracker coordinates service value calculation for individual servers and updates global statistics

func NewValueTracker Uses

func NewValueTracker(db ethdb.KeyValueStore, clock mclock.Clock, reqInfo []RequestInfo, updatePeriod time.Duration, transferRate, statsExpRate, offlineExpRate float64) *ValueTracker

NewValueTracker creates a new ValueTracker and loads its previously saved state from the database if possible.

func (*ValueTracker) GetNode Uses

func (vt *ValueTracker) GetNode(id enode.ID) *NodeValueTracker

GetNode returns an individual server node's value tracker. If it did not exist before then a new node is created.

func (*ValueTracker) Register Uses

func (vt *ValueTracker) Register(id enode.ID) *NodeValueTracker

Register adds a server node to the value tracker

func (*ValueTracker) RequestStats Uses

func (vt *ValueTracker) RequestStats() []RequestStatsItem

RequestStats returns the current contents of the reference request basket, with request values meaning average per request rather than total.

func (*ValueTracker) RtStats Uses

func (vt *ValueTracker) RtStats() ResponseTimeStats

RtStats returns the global response time distribution statistics

func (*ValueTracker) Served Uses

func (vt *ValueTracker) Served(nv *NodeValueTracker, reqs []ServedRequest, respTime time.Duration)

Served adds a served request to the node's statistics. An actual request may be composed of one or more request types (service vector indices).

func (*ValueTracker) StatsExpFactor Uses

func (vt *ValueTracker) StatsExpFactor() utils.ExpirationFactor

StatsExpirer returns the current expiration factor so that other values can be expired with the same rate as the service value statistics.

func (*ValueTracker) StatsExpirer Uses

func (vt *ValueTracker) StatsExpirer() *utils.Expirer

StatsExpirer returns the statistics expirer so that other values can be expired with the same rate as the service value statistics.

func (*ValueTracker) Stop Uses

func (vt *ValueTracker) Stop()

Stop saves the value tracker's state and each loaded node's individual state and returns after shutting the internal goroutines down.

func (*ValueTracker) Unregister Uses

func (vt *ValueTracker) Unregister(id enode.ID)

Unregister removes a server node from the value tracker

func (*ValueTracker) UpdateCosts Uses

func (vt *ValueTracker) UpdateCosts(nv *NodeValueTracker, reqCosts []uint64)

UpdateCosts updates the node value tracker's request cost table

type WrsIterator Uses

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

WrsIterator returns nodes from the specified selectable set with a weighted random selection. Selection weights are provided by a callback function.

func NewWrsIterator Uses

func NewWrsIterator(ns *nodestate.NodeStateMachine, requireFlags, disableFlags nodestate.Flags, weightField nodestate.Field) *WrsIterator

NewWrsIterator creates a new WrsIterator. Nodes are selectable if they have all the required and none of the disabled flags set. When a node is selected the selectedFlag is set which also disables further selectability until it is removed or times out.

func (*WrsIterator) Close Uses

func (w *WrsIterator) Close()

Close ends the iterator.

func (*WrsIterator) Next Uses

func (w *WrsIterator) Next() bool

Next selects the next node.

func (*WrsIterator) Node Uses

func (w *WrsIterator) Node() *enode.Node

Node returns the current node.

Package client imports 13 packages (graph) and is imported by 10 packages. Updated 2020-06-02. Refresh now. Tools for package owners.