docs(proxy): improve AX usage comments
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
b9b3c47b4c
commit
b5e4a6499f
2 changed files with 14 additions and 4 deletions
|
|
@ -1264,8 +1264,8 @@ func (m *Miner) Close() {
|
||||||
|
|
||||||
// NewStats creates zeroed global metrics.
|
// NewStats creates zeroed global metrics.
|
||||||
//
|
//
|
||||||
// stats := proxy.NewStats()
|
// stats := proxy.NewStats()
|
||||||
// bus.Subscribe(proxy.EventAccept, stats.OnAccept)
|
// _ = stats.Summary()
|
||||||
func NewStats() *Stats {
|
func NewStats() *Stats {
|
||||||
stats := &Stats{startTime: time.Now().UTC(), latency: make([]uint16, 0, 1024)}
|
stats := &Stats{startTime: time.Now().UTC(), latency: make([]uint16, 0, 1024)}
|
||||||
stats.windows[HashrateWindow60s] = newTickWindow(60)
|
stats.windows[HashrateWindow60s] = newTickWindow(60)
|
||||||
|
|
@ -1304,6 +1304,8 @@ func (s *Stats) OnClose(e Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnAccept records an accepted share.
|
// OnAccept records an accepted share.
|
||||||
|
//
|
||||||
|
// stats.OnAccept(proxy.Event{Diff: 100000, Latency: 82})
|
||||||
func (s *Stats) OnAccept(e Event) {
|
func (s *Stats) OnAccept(e Event) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -1329,6 +1331,8 @@ func (s *Stats) OnAccept(e Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnReject records a rejected share.
|
// OnReject records a rejected share.
|
||||||
|
//
|
||||||
|
// stats.OnReject(proxy.Event{Error: "Low difficulty share"})
|
||||||
func (s *Stats) OnReject(e Event) {
|
func (s *Stats) OnReject(e Event) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -1340,6 +1344,8 @@ func (s *Stats) OnReject(e Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tick advances the rolling windows.
|
// Tick advances the rolling windows.
|
||||||
|
//
|
||||||
|
// stats.Tick()
|
||||||
func (s *Stats) Tick() {
|
func (s *Stats) Tick() {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
|
|
@ -1356,6 +1362,8 @@ func (s *Stats) Tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Summary returns a snapshot of the current metrics.
|
// Summary returns a snapshot of the current metrics.
|
||||||
|
//
|
||||||
|
// summary := stats.Summary()
|
||||||
func (s *Stats) Summary() StatsSummary {
|
func (s *Stats) Summary() StatsSummary {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return StatsSummary{}
|
return StatsSummary{}
|
||||||
|
|
@ -1591,6 +1599,8 @@ func (w *Workers) Tick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hashrate returns the configured worker hashrate window.
|
// Hashrate returns the configured worker hashrate window.
|
||||||
|
//
|
||||||
|
// hr60 := record.Hashrate(60)
|
||||||
func (r *WorkerRecord) Hashrate(seconds int) float64 {
|
func (r *WorkerRecord) Hashrate(seconds int) float64 {
|
||||||
if r == nil || seconds <= 0 {
|
if r == nil || seconds <= 0 {
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
// Workers tracks per-identity aggregates derived from miner login fields.
|
// Workers tracks per-identity aggregates derived from miner login fields.
|
||||||
//
|
//
|
||||||
// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus)
|
// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus)
|
||||||
// records := workers.List()
|
// workers.OnLogin(proxy.Event{Miner: miner})
|
||||||
type Workers struct {
|
type Workers struct {
|
||||||
mode WorkersMode
|
mode WorkersMode
|
||||||
entries []WorkerRecord // ordered by first-seen (stable)
|
entries []WorkerRecord // ordered by first-seen (stable)
|
||||||
|
|
@ -20,7 +20,7 @@ type Workers struct {
|
||||||
|
|
||||||
// WorkerRecord is the aggregate row returned by Workers.List().
|
// WorkerRecord is the aggregate row returned by Workers.List().
|
||||||
//
|
//
|
||||||
// record.Hashrate(60)
|
// hr60 := record.Hashrate(60)
|
||||||
type WorkerRecord struct {
|
type WorkerRecord struct {
|
||||||
Name string
|
Name string
|
||||||
LastIP string
|
LastIP string
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue