Documentation
¶
Overview ¶
Package avgcounter implements a simple EMA (Exponential Moving Average) counter. The New function creates a counter with the only parameter: avgInterval. Every Add call adds the value to the counter. The current value can be obtained using the Value method.
The counter holds the exponentially (by time) weighted average of all added values.
Index ¶
- Constants
- func GHSToHS(hrGHS int) float64
- func GHSToJobSubmitted(hrGHS float64) float64
- func GHSToJobSubmittedV2(hrGHS float64, duration time.Duration) float64
- func HSToGHS(hashrateHS float64) int
- func HSToJobSubmitted(hrHS float64) float64
- func JobSubmittedToGHS(jobSubmitted float64) float64
- func JobSubmittedToGHSV2(jobSubmitted float64, duration time.Duration) float64
- func JobSubmittedToHS(jobSubmitted float64) float64
- type Counter
- type Ema
- type GlobalHashrate
- func (t *GlobalHashrate) GetAll() map[string]time.Time
- func (t *GlobalHashrate) GetHashRateGHS(workerName string, counterID string) (hrGHS float64, ok bool)
- func (t *GlobalHashrate) GetHashRateGHSAll(workerName string) (hrGHS map[string]float64, ok bool)
- func (t *GlobalHashrate) GetLastSubmitTime(workerName string) (tm time.Time, ok bool)
- func (t *GlobalHashrate) GetTotalWork(workerName string) (work float64, ok bool)
- func (t *GlobalHashrate) GetWorker(workerName string) *WorkerHashrateModel
- func (t *GlobalHashrate) Initialize(workerName string)
- func (t *GlobalHashrate) OnConnect(workerName string)
- func (t *GlobalHashrate) OnSubmit(workerName string, diff float64)
- func (t *GlobalHashrate) Range(f func(m *WorkerHashrateModel) bool)
- func (t *GlobalHashrate) Reset(workerName string)
- type Hashrate
- func (h *Hashrate) GetHashrateAvgGHSAll() map[string]float64
- func (h *Hashrate) GetHashrateAvgGHSCustom(ID string) (hrGHS float64, ok bool)
- func (h *Hashrate) GetLastSubmitTime() time.Time
- func (h *Hashrate) GetTotalDuration() time.Duration
- func (h *Hashrate) GetTotalShares() int
- func (h *Hashrate) GetTotalWork() float64
- func (h *Hashrate) OnSubmit(diff float64)
- func (h *Hashrate) Reset()
- func (h *Hashrate) Start()
- type HashrateFactory
- type Mean
- func (h *Mean) Add(diff float64)
- func (h *Mean) GetLastSubmitTime() time.Time
- func (h *Mean) GetTotalDuration() time.Duration
- func (h *Mean) GetTotalShares() uint32
- func (h *Mean) GetTotalWork() uint64
- func (h *Mean) Reset()
- func (h *Mean) Start()
- func (h *Mean) Value() float64
- func (h *Mean) ValuePer(t time.Duration) float64
- type Sma
- type WorkerHashrateModel
- func (m *WorkerHashrateModel) GetHashRateGHS(counterID string) (float64, bool)
- func (m *WorkerHashrateModel) GetHashrateAvgGHSAll() map[string]float64
- func (m *WorkerHashrateModel) GetHashrateCounter(counterID string) Counter
- func (m *WorkerHashrateModel) GetLastSubmitTime() time.Time
- func (m *WorkerHashrateModel) GetTotalShares() int
- func (m *WorkerHashrateModel) ID() string
- func (m *WorkerHashrateModel) OnConnect()
- func (m *WorkerHashrateModel) OnSubmit(diff float64)
- func (m *WorkerHashrateModel) Reconnects() int
Constants ¶
const MeanCounterKey = "mean"
Variables ¶
This section is empty.
Functions ¶
func GHSToJobSubmitted ¶
func HSToJobSubmitted ¶
func JobSubmittedToGHS ¶
func JobSubmittedToGHSV2 ¶
func JobSubmittedToHS ¶
Types ¶
type Ema ¶
type Ema struct {
// contains filtered or unexported fields
}
Ema is an EMA (Exponential Moving Average) counter.
func NewEma ¶
NewEma creates a new Counter with the given half-life (time lag at which the exponential weights decay by one half)
type GlobalHashrate ¶
type GlobalHashrate struct {
// contains filtered or unexported fields
}
func NewGlobalHashrate ¶
func NewGlobalHashrate(hrFactory HashrateFactory) *GlobalHashrate
func (*GlobalHashrate) GetHashRateGHS ¶
func (t *GlobalHashrate) GetHashRateGHS(workerName string, counterID string) (hrGHS float64, ok bool)
func (*GlobalHashrate) GetHashRateGHSAll ¶
func (t *GlobalHashrate) GetHashRateGHSAll(workerName string) (hrGHS map[string]float64, ok bool)
func (*GlobalHashrate) GetLastSubmitTime ¶
func (t *GlobalHashrate) GetLastSubmitTime(workerName string) (tm time.Time, ok bool)
func (*GlobalHashrate) GetTotalWork ¶
func (t *GlobalHashrate) GetTotalWork(workerName string) (work float64, ok bool)
func (*GlobalHashrate) GetWorker ¶
func (t *GlobalHashrate) GetWorker(workerName string) *WorkerHashrateModel
func (*GlobalHashrate) Initialize ¶
func (t *GlobalHashrate) Initialize(workerName string)
func (*GlobalHashrate) OnConnect ¶
func (t *GlobalHashrate) OnConnect(workerName string)
func (*GlobalHashrate) OnSubmit ¶
func (t *GlobalHashrate) OnSubmit(workerName string, diff float64)
func (*GlobalHashrate) Range ¶
func (t *GlobalHashrate) Range(f func(m *WorkerHashrateModel) bool)
func (*GlobalHashrate) Reset ¶
func (t *GlobalHashrate) Reset(workerName string)
type Hashrate ¶
type Hashrate struct {
// contains filtered or unexported fields
}
func NewHashrate ¶
func (*Hashrate) GetHashrateAvgGHSAll ¶
func (*Hashrate) GetHashrateAvgGHSCustom ¶
func (*Hashrate) GetLastSubmitTime ¶
func (*Hashrate) GetTotalDuration ¶
func (*Hashrate) GetTotalShares ¶
func (*Hashrate) GetTotalWork ¶
type HashrateFactory ¶
type HashrateFactory = func() *Hashrate
type Mean ¶
type Mean struct {
// contains filtered or unexported fields
}
func NewMean ¶
func NewMean() *Mean
NewMean creates a new Mean hashrate counter, which adds all submitted work and divides it by the total duration it is also used to track the first and last submit time and total work
func (*Mean) GetLastSubmitTime ¶
func (*Mean) GetTotalDuration ¶
func (*Mean) GetTotalShares ¶
func (*Mean) GetTotalWork ¶
type Sma ¶
type Sma struct {
// contains filtered or unexported fields
}
Sma is an SMA (Simple Moving Average) counter.
func (*Sma) AddWithTimestamp ¶
Add adds a new value to the counter.
type WorkerHashrateModel ¶
type WorkerHashrateModel struct {
// contains filtered or unexported fields
}
func NewWorkerHashrateModel ¶
func NewWorkerHashrateModel(id string, hr *Hashrate) *WorkerHashrateModel
func (*WorkerHashrateModel) GetHashRateGHS ¶
func (m *WorkerHashrateModel) GetHashRateGHS(counterID string) (float64, bool)
func (*WorkerHashrateModel) GetHashrateAvgGHSAll ¶
func (m *WorkerHashrateModel) GetHashrateAvgGHSAll() map[string]float64
func (*WorkerHashrateModel) GetHashrateCounter ¶
func (m *WorkerHashrateModel) GetHashrateCounter(counterID string) Counter
func (*WorkerHashrateModel) GetLastSubmitTime ¶
func (m *WorkerHashrateModel) GetLastSubmitTime() time.Time
func (*WorkerHashrateModel) GetTotalShares ¶
func (m *WorkerHashrateModel) GetTotalShares() int
func (*WorkerHashrateModel) ID ¶
func (m *WorkerHashrateModel) ID() string
func (*WorkerHashrateModel) OnConnect ¶
func (m *WorkerHashrateModel) OnConnect()
func (*WorkerHashrateModel) OnSubmit ¶
func (m *WorkerHashrateModel) OnSubmit(diff float64)
func (*WorkerHashrateModel) Reconnects ¶
func (m *WorkerHashrateModel) Reconnects() int