Documentation ¶
Index ¶
- Constants
- Variables
- func CumulativeProbabilityFunctionForPoissonDist(k_events uint64, lambda float64) float64
- type ConcurrentBlockStore
- type Entry
- type Exploration
- type ProviderData
- type ProviderOptimizer
- func (po *ProviderOptimizer) AppendProbeRelayData(providerAddress string, latency time.Duration, success bool)
- func (po *ProviderOptimizer) AppendRelayData(providerAddress string, latency time.Duration, isHangingApi bool, ...)
- func (po *ProviderOptimizer) AppendRelayFailure(providerAddress string)
- func (po *ProviderOptimizer) CalculateProbabilityOfBlockError(requestedBlock int64, providerData ProviderData) float64
- func (po *ProviderOptimizer) CalculateProbabilityOfTimeout(availabilityScore score.ScoreStore) float64
- func (po *ProviderOptimizer) CalculateQoSScoresForMetrics(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, ...) []*metrics.OptimizerQoSReport
- func (po *ProviderOptimizer) CalculateSelectionTiers(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, ...) (SelectionTier, Exploration, map[string]*metrics.OptimizerQoSReport)
- func (po *ProviderOptimizer) ChooseProvider(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, ...) (addresses []string, tier int)
- func (po *ProviderOptimizer) GetExcellenceQoSReportForProvider(providerAddress string) (qosReport *pairingtypes.QualityOfServiceReport, ...)
- func (po *ProviderOptimizer) Strategy() Strategy
- func (po *ProviderOptimizer) UpdateWeights(weights map[string]int64, epoch uint64)
- type SelectionTier
- type SelectionTierInst
- func (st *SelectionTierInst) AddScore(entry string, score float64)
- func (st *SelectionTierInst) GetRawScores() []Entry
- func (st *SelectionTierInst) GetTier(tier int, numTiers int, minimumEntries int) []Entry
- func (st *SelectionTierInst) ScoresCount() int
- func (st *SelectionTierInst) SelectTierRandomly(numTiers int, tierChances map[int]float64) int
- func (st *SelectionTierInst) ShiftTierChance(numTiers int, initialTierChances map[int]float64) map[int]float64
- type SelectionWeighter
- type Strategy
Constants ¶
View Source
const ( CacheMaxCost = 20000 // each item cost would be 1 CacheNumCounters = 20000 // expect 2000 items INITIAL_DATA_STALENESS = 24 HALF_LIFE_TIME = time.Hour MAX_HALF_TIME = 3 * time.Hour PROBE_UPDATE_WEIGHT = 0.25 RELAY_UPDATE_WEIGHT = 1 DEFAULT_EXPLORATION_CHANCE = 0.1 COST_EXPLORATION_CHANCE = 0.01 WANTED_PRECISION = int64(8) )
Variables ¶
View Source
var ( OptimizerNumTiers = 4 MinimumEntries = 5 ATierChance = 0.75 LastTierChance = 0.0 )
Functions ¶
Types ¶
type ConcurrentBlockStore ¶
type Exploration ¶ added in v3.1.7
type Exploration struct {
// contains filtered or unexported fields
}
type ProviderData ¶
type ProviderData struct { Availability score.ScoreStore // will be used to calculate the probability of error Latency score.ScoreStore // will be used to calculate the latency score Sync score.ScoreStore // will be used to calculate the sync score for spectypes.LATEST_BLOCK/spectypes.NOT_APPLICABLE requests SyncBlock uint64 // will be used to calculate the probability of block error LatencyRaw score.ScoreStore // will be used when reporting reputation to the node (Latency = LatencyRaw / baseLatency) SyncRaw score.ScoreStore // will be used when reporting reputation to the node (Sync = SyncRaw / baseSync) }
type ProviderOptimizer ¶
type ProviderOptimizer struct { OptimizerNumTiers int // contains filtered or unexported fields }
func NewProviderOptimizer ¶
func (*ProviderOptimizer) AppendProbeRelayData ¶
func (po *ProviderOptimizer) AppendProbeRelayData(providerAddress string, latency time.Duration, success bool)
func (*ProviderOptimizer) AppendRelayData ¶
func (*ProviderOptimizer) AppendRelayFailure ¶
func (po *ProviderOptimizer) AppendRelayFailure(providerAddress string)
func (*ProviderOptimizer) CalculateProbabilityOfBlockError ¶
func (po *ProviderOptimizer) CalculateProbabilityOfBlockError(requestedBlock int64, providerData ProviderData) float64
func (*ProviderOptimizer) CalculateProbabilityOfTimeout ¶
func (po *ProviderOptimizer) CalculateProbabilityOfTimeout(availabilityScore score.ScoreStore) float64
func (*ProviderOptimizer) CalculateQoSScoresForMetrics ¶ added in v3.2.2
func (po *ProviderOptimizer) CalculateQoSScoresForMetrics(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, requestedBlock int64) []*metrics.OptimizerQoSReport
func (*ProviderOptimizer) CalculateSelectionTiers ¶ added in v3.1.7
func (po *ProviderOptimizer) CalculateSelectionTiers(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, requestedBlock int64) (SelectionTier, Exploration, map[string]*metrics.OptimizerQoSReport)
func (*ProviderOptimizer) ChooseProvider ¶
func (po *ProviderOptimizer) ChooseProvider(allAddresses []string, ignoredProviders map[string]struct{}, cu uint64, requestedBlock int64) (addresses []string, tier int)
returns a sub set of selected providers according to their scores, perturbation factor will be added to each score in order to randomly select providers that are not always on top
func (*ProviderOptimizer) GetExcellenceQoSReportForProvider ¶
func (po *ProviderOptimizer) GetExcellenceQoSReportForProvider(providerAddress string) (qosReport *pairingtypes.QualityOfServiceReport, rawQosReport *pairingtypes.QualityOfServiceReport)
func (*ProviderOptimizer) Strategy ¶
func (po *ProviderOptimizer) Strategy() Strategy
func (*ProviderOptimizer) UpdateWeights ¶ added in v3.1.7
func (po *ProviderOptimizer) UpdateWeights(weights map[string]int64, epoch uint64)
type SelectionTier ¶ added in v3.1.7
type SelectionTier interface { AddScore(entry string, score float64) GetTier(tier int, numTiers int, minimumEntries int) []Entry SelectTierRandomly(numTiers int, tierChances map[int]float64) int ShiftTierChance(numTiers int, initialYierChances map[int]float64) map[int]float64 ScoresCount() int GetRawScores() []Entry }
selectionTier is a utility to get a tier of addresses based on their scores
func NewSelectionTier ¶ added in v3.1.7
func NewSelectionTier() SelectionTier
type SelectionTierInst ¶ added in v3.1.7
type SelectionTierInst struct {
// contains filtered or unexported fields
}
func (*SelectionTierInst) AddScore ¶ added in v3.1.7
func (st *SelectionTierInst) AddScore(entry string, score float64)
func (*SelectionTierInst) GetRawScores ¶ added in v3.2.2
func (st *SelectionTierInst) GetRawScores() []Entry
func (*SelectionTierInst) GetTier ¶ added in v3.1.7
func (st *SelectionTierInst) GetTier(tier int, numTiers int, minimumEntries int) []Entry
func (*SelectionTierInst) ScoresCount ¶ added in v3.1.7
func (st *SelectionTierInst) ScoresCount() int
func (*SelectionTierInst) SelectTierRandomly ¶ added in v3.1.7
func (st *SelectionTierInst) SelectTierRandomly(numTiers int, tierChances map[int]float64) int
func (*SelectionTierInst) ShiftTierChance ¶ added in v3.1.7
type SelectionWeighter ¶ added in v3.1.7
type SelectionWeighter interface { Weight(address string) int64 SetWeights(weights map[string]int64) WeightedChoice(possibilities []Entry) string }
SelectionWeighter is a utility to select an address based on a weight.
func NewSelectionWeighter ¶ added in v3.1.7
func NewSelectionWeighter() SelectionWeighter
Click to show internal directories.
Click to hide internal directories.