docs(proxy): tighten AX-oriented comments
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
75d151b4e5
commit
031f0c0f17
2 changed files with 11 additions and 22 deletions
19
stats.go
19
stats.go
|
|
@ -6,13 +6,11 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stats tracks proxy-wide counters and rolling hashrate windows.
|
// stats := proxy.NewStats()
|
||||||
//
|
// bus.Subscribe(proxy.EventAccept, stats.OnAccept)
|
||||||
// stats := proxy.NewStats()
|
// bus.Subscribe(proxy.EventReject, stats.OnReject)
|
||||||
// bus.Subscribe(proxy.EventAccept, stats.OnAccept)
|
// stats.Tick()
|
||||||
// bus.Subscribe(proxy.EventReject, stats.OnReject)
|
// _ = stats.Summary()
|
||||||
// stats.Tick()
|
|
||||||
// _ = stats.Summary()
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
accepted atomic.Uint64
|
accepted atomic.Uint64
|
||||||
rejected atomic.Uint64
|
rejected atomic.Uint64
|
||||||
|
|
@ -29,9 +27,6 @@ type Stats struct {
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// HashrateWindow60s selects the 60-second hashrate window.
|
|
||||||
//
|
|
||||||
// proxy.HashrateWindow60s
|
|
||||||
const (
|
const (
|
||||||
HashrateWindow60s = 0 // 1 minute
|
HashrateWindow60s = 0 // 1 minute
|
||||||
HashrateWindow600s = 1 // 10 minutes
|
HashrateWindow600s = 1 // 10 minutes
|
||||||
|
|
@ -50,9 +45,7 @@ type tickWindow struct {
|
||||||
size int // window size in seconds = len(buckets)
|
size int // window size in seconds = len(buckets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatsSummary is the serialisable snapshot returned by Stats.Summary().
|
// summary := proxy.NewStats().Summary()
|
||||||
//
|
|
||||||
// summary := proxy.NewStats().Summary()
|
|
||||||
type StatsSummary struct {
|
type StatsSummary struct {
|
||||||
Accepted uint64 `json:"accepted"`
|
Accepted uint64 `json:"accepted"`
|
||||||
Rejected uint64 `json:"rejected"`
|
Rejected uint64 `json:"rejected"`
|
||||||
|
|
|
||||||
14
worker.go
14
worker.go
|
|
@ -5,11 +5,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Workers tracks per-worker aggregates derived from miner login fields.
|
// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus)
|
||||||
//
|
// workers.OnLogin(proxy.Event{Miner: &proxy.Miner{rigID: "rig-alpha", user: "WALLET", ip: "10.0.0.1"}})
|
||||||
// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus)
|
// _ = workers.List()
|
||||||
// workers.OnLogin(proxy.Event{Miner: &proxy.Miner{rigID: "rig-alpha", user: "WALLET", ip: "10.0.0.1"}})
|
|
||||||
// _ = workers.List()
|
|
||||||
type Workers struct {
|
type Workers struct {
|
||||||
mode WorkersMode
|
mode WorkersMode
|
||||||
entries []WorkerRecord // ordered by first-seen (stable)
|
entries []WorkerRecord // ordered by first-seen (stable)
|
||||||
|
|
@ -19,10 +17,8 @@ type Workers struct {
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkerRecord is the aggregate row returned by `Workers.List()`.
|
// record := proxy.WorkerRecord{Name: "rig-alpha"}
|
||||||
//
|
// _ = record.Hashrate(60)
|
||||||
// record := proxy.WorkerRecord{Name: "rig-alpha"}
|
|
||||||
// _ = 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