From 187a366d748aeff004d11da6e596e7106b694c49 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 22:20:39 +0000 Subject: [PATCH] refactor(proxy): align aggregate field names with RFC Co-Authored-By: Virgil --- api/router.go | 4 ++-- state_impl.go | 18 +++++++++--------- stats.go | 2 +- worker.go | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/api/router.go b/api/router.go index 80a6e43..0ed146f 100644 --- a/api/router.go +++ b/api/router.go @@ -141,7 +141,7 @@ func summaryResponse(p *proxy.Proxy) SummaryResponse { Expired: summary.Expired, AvgTime: summary.AvgTime, Latency: summary.AvgLatency, - HashesTotal: summary.HashesTotal, + HashesTotal: summary.Hashes, Best: summary.TopDiff, }, } @@ -158,7 +158,7 @@ func workersResponse(p *proxy.Proxy) WorkersResponse { record.Accepted, record.Rejected, record.Invalid, - record.HashesTotal, + record.Hashes, unixOrZero(record.LastHashAt), record.Hashrate(60), record.Hashrate(600), diff --git a/state_impl.go b/state_impl.go index b076c80..1dff295 100644 --- a/state_impl.go +++ b/state_impl.go @@ -641,7 +641,7 @@ func (p *Proxy) summaryDocument() summaryDocumentPayload { Expired: summary.Expired, AvgTime: summary.AvgTime, Latency: summary.AvgLatency, - HashesTotal: summary.HashesTotal, + HashesTotal: summary.Hashes, Best: summary.TopDiff, }, } @@ -658,7 +658,7 @@ func (p *Proxy) workersDocument() workersDocumentPayload { record.Accepted, record.Rejected, record.Invalid, - record.HashesTotal, + record.Hashes, unixOrZero(record.LastHashAt), record.Hashrate(60), record.Hashrate(600), @@ -1284,11 +1284,11 @@ func (s *Stats) Summary() StatsSummary { s.mu.Lock() defer s.mu.Unlock() summary := StatsSummary{ - Accepted: s.accepted.Load(), - Rejected: s.rejected.Load(), - Invalid: s.invalid.Load(), - Expired: s.expired.Load(), - HashesTotal: s.hashes.Load(), + Accepted: s.accepted.Load(), + Rejected: s.rejected.Load(), + Invalid: s.invalid.Load(), + Expired: s.expired.Load(), + Hashes: s.hashes.Load(), } if summary.Accepted > 0 { uptime := uint64(time.Since(s.startTime).Seconds()) @@ -1307,7 +1307,7 @@ func (s *Stats) Summary() StatsSummary { if i == HashrateWindowAll { uptime := time.Since(s.startTime).Seconds() if uptime > 0 { - summary.Hashrate[i] = float64(summary.HashesTotal) / uptime + summary.Hashrate[i] = float64(summary.Hashes) / uptime } continue } @@ -1445,7 +1445,7 @@ func (w *Workers) OnAccept(e Event) { } record := &w.entries[index] record.Accepted++ - record.HashesTotal += e.Diff + record.Hashes += e.Diff record.LastHashAt = time.Now().UTC() record.LastIP = e.Miner.ip for i := range record.windows { diff --git a/stats.go b/stats.go index aa9d649..ca03d7d 100644 --- a/stats.go +++ b/stats.go @@ -53,7 +53,7 @@ type StatsSummary struct { Rejected uint64 `json:"rejected"` Invalid uint64 `json:"invalid"` Expired uint64 `json:"expired"` - HashesTotal uint64 `json:"hashes_total"` + Hashes uint64 `json:"hashes_total"` AvgTime uint32 `json:"avg_time"` // seconds per accepted share AvgLatency uint32 `json:"latency"` // median pool response latency in ms Hashrate [6]float64 `json:"hashrate"` // H/s per window (index = HashrateWindow* constants) diff --git a/worker.go b/worker.go index e14585b..8bd1db3 100644 --- a/worker.go +++ b/worker.go @@ -28,7 +28,7 @@ type WorkerRecord struct { Accepted uint64 Rejected uint64 Invalid uint64 - HashesTotal uint64 // sum of accepted share difficulties + Hashes uint64 // sum of accepted share difficulties LastHashAt time.Time windows [5]tickWindow // 60s, 600s, 3600s, 12h, 24h }