go-proxy/worker.go
Virgil 3d64079f91 feat: scaffold go-proxy from RFC spec
Stratum mining proxy library skeleton with 18 Go source files, type
declarations, event bus, NiceHash/simple splitter packages, pool client,
HTTP API types, access/share logging, and rate limiter. No function
implementations — ready for agent dispatch.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-04 11:16:28 +01:00

33 lines
871 B
Go

package proxy
import (
"sync"
"time"
)
// Workers maintains per-worker aggregate stats. Workers are identified by name,
// derived from the miner's login fields per WorkersMode.
//
// w := proxy.NewWorkers(proxy.WorkersByRigID, bus)
type Workers struct {
mode WorkersMode
entries []WorkerRecord // ordered by first-seen (stable)
nameIndex map[string]int // workerName → entries index
idIndex map[int64]int // minerID → entries index
mu sync.RWMutex
}
// WorkerRecord is the per-identity aggregate.
//
// hr60 := record.Hashrate(60)
type WorkerRecord struct {
Name string
LastIP string
Connections uint64
Accepted uint64
Rejected uint64
Invalid uint64
Hashes uint64 // sum of accepted share difficulties
LastHashAt time.Time
windows [5]tickWindow // 60s, 600s, 3600s, 12h, 24h
}