refactor(proxy): rename hash totals for clarity
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
6d6934f37b
commit
8b47e6a11b
6 changed files with 20 additions and 20 deletions
|
|
@ -125,7 +125,7 @@ func summaryResponse(p *proxy.Proxy) SummaryResponse {
|
|||
Expired: summary.Expired,
|
||||
AvgTime: summary.AvgTime,
|
||||
Latency: summary.AvgLatency,
|
||||
HashesTotal: summary.Hashes,
|
||||
HashesTotal: summary.HashesTotal,
|
||||
Best: summary.TopDiff,
|
||||
},
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ func workersResponse(p *proxy.Proxy) any {
|
|||
record.Accepted,
|
||||
record.Rejected,
|
||||
record.Invalid,
|
||||
record.Hashes,
|
||||
record.HashesTotal,
|
||||
unixOrZero(record.LastHashAt),
|
||||
record.Hashrate(60),
|
||||
record.Hashrate(600),
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import (
|
|||
|
||||
// CustomDiffBucketStats tracks per-custom-difficulty share outcomes.
|
||||
type CustomDiffBucketStats struct {
|
||||
Accepted uint64 `json:"accepted"`
|
||||
Rejected uint64 `json:"rejected"`
|
||||
Invalid uint64 `json:"invalid"`
|
||||
Expired uint64 `json:"expired"`
|
||||
Hashes uint64 `json:"hashes_total"`
|
||||
Accepted uint64 `json:"accepted"`
|
||||
Rejected uint64 `json:"rejected"`
|
||||
Invalid uint64 `json:"invalid"`
|
||||
Expired uint64 `json:"expired"`
|
||||
HashesTotal uint64 `json:"hashes_total"`
|
||||
}
|
||||
|
||||
// CustomDiffBuckets records share totals grouped by miner custom difficulty.
|
||||
|
|
@ -52,7 +52,7 @@ func (b *CustomDiffBuckets) OnAccept(e Event) {
|
|||
bucket.Expired++
|
||||
}
|
||||
if e.Diff > 0 {
|
||||
bucket.Hashes += e.Diff
|
||||
bucket.HashesTotal += e.Diff
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ func TestProxy_CustomDiffStats_Good(t *testing.T) {
|
|||
if !ok {
|
||||
t.Fatalf("expected custom diff bucket 50000 to be present")
|
||||
}
|
||||
if bucket.Accepted != 1 || bucket.Expired != 1 || bucket.Hashes != 75 {
|
||||
if bucket.Accepted != 1 || bucket.Expired != 1 || bucket.HashesTotal != 75 {
|
||||
t.Fatalf("unexpected bucket totals: %+v", bucket)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -645,7 +645,7 @@ func (p *Proxy) summaryDocument() summaryDocumentPayload {
|
|||
Expired: summary.Expired,
|
||||
AvgTime: summary.AvgTime,
|
||||
Latency: summary.AvgLatency,
|
||||
HashesTotal: summary.Hashes,
|
||||
HashesTotal: summary.HashesTotal,
|
||||
Best: summary.TopDiff,
|
||||
},
|
||||
}
|
||||
|
|
@ -662,7 +662,7 @@ func (p *Proxy) workersDocument() workersDocumentPayload {
|
|||
record.Accepted,
|
||||
record.Rejected,
|
||||
record.Invalid,
|
||||
record.Hashes,
|
||||
record.HashesTotal,
|
||||
unixOrZero(record.LastHashAt),
|
||||
record.Hashrate(60),
|
||||
record.Hashrate(600),
|
||||
|
|
@ -1283,11 +1283,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(),
|
||||
Hashes: s.hashes.Load(),
|
||||
Accepted: s.accepted.Load(),
|
||||
Rejected: s.rejected.Load(),
|
||||
Invalid: s.invalid.Load(),
|
||||
Expired: s.expired.Load(),
|
||||
HashesTotal: s.hashes.Load(),
|
||||
}
|
||||
if summary.Accepted > 0 {
|
||||
uptime := uint64(time.Since(s.startTime).Seconds())
|
||||
|
|
@ -1306,7 +1306,7 @@ func (s *Stats) Summary() StatsSummary {
|
|||
if i == HashrateWindowAll {
|
||||
uptime := time.Since(s.startTime).Seconds()
|
||||
if uptime > 0 {
|
||||
summary.Hashrate[i] = float64(summary.Hashes) / uptime
|
||||
summary.Hashrate[i] = float64(summary.HashesTotal) / uptime
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
|
@ -1441,7 +1441,7 @@ func (w *Workers) OnAccept(e Event) {
|
|||
}
|
||||
record := &w.entries[index]
|
||||
record.Accepted++
|
||||
record.Hashes += e.Diff
|
||||
record.HashesTotal += e.Diff
|
||||
record.LastHashAt = time.Now().UTC()
|
||||
record.LastIP = e.Miner.ip
|
||||
for i := range record.windows {
|
||||
|
|
|
|||
2
stats.go
2
stats.go
|
|
@ -53,7 +53,7 @@ type StatsSummary struct {
|
|||
Rejected uint64 `json:"rejected"`
|
||||
Invalid uint64 `json:"invalid"`
|
||||
Expired uint64 `json:"expired"`
|
||||
Hashes uint64 `json:"hashes_total"`
|
||||
HashesTotal 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)
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ type WorkerRecord struct {
|
|||
Accepted uint64
|
||||
Rejected uint64
|
||||
Invalid uint64
|
||||
Hashes uint64 // sum of accepted share difficulties
|
||||
HashesTotal uint64 // sum of accepted share difficulties
|
||||
LastHashAt time.Time
|
||||
windows [5]tickWindow // 60s, 600s, 3600s, 12h, 24h
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue