docs: align public API comments with AX guidance

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-05 02:58:56 +00:00
parent 1ae781608c
commit af96bfce94
3 changed files with 29 additions and 4 deletions

View file

@ -57,7 +57,10 @@ func splitterFactoryForMode(mode string) (func(*Config, *EventBus) Splitter, boo
}
// cfg, result := proxy.LoadConfig("/etc/proxy.json")
// if !result.OK { return result.Error }
//
// if !result.OK {
// return result.Error
// }
func LoadConfig(path string) (*Config, Result) {
data, err := os.ReadFile(path)
if err != nil {
@ -72,8 +75,16 @@ func LoadConfig(path string) (*Config, Result) {
return config, config.Validate()
}
// cfg := &proxy.Config{Mode: "nicehash", Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}, Workers: proxy.WorkersByRigID}
// if result := cfg.Validate(); !result.OK { return result }
// cfg := &proxy.Config{
// Mode: "nicehash",
// Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}},
// Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}},
// Workers: proxy.WorkersByRigID,
// }
//
// if result := cfg.Validate(); !result.OK {
// return result
// }
func (c *Config) Validate() Result {
if c == nil {
return newErrorResult(NewScopedError("proxy.config", "config is nil", nil))
@ -117,7 +128,10 @@ func isValidWorkersMode(mode WorkersMode) bool {
}
// bus := proxy.NewEventBus()
// bus.Subscribe(proxy.EventLogin, func(e proxy.Event) { _ = e.Miner })
//
// bus.Subscribe(proxy.EventLogin, func(e proxy.Event) {
// _ = e.Miner
// })
func NewEventBus() *EventBus {
return &EventBus{listeners: make(map[EventType][]EventHandler)}
}

View file

@ -1515,6 +1515,8 @@ func workerNameFor(mode WorkersMode, miner *Miner) string {
}
// OnLogin creates or updates a worker record.
//
// workers.OnLogin(proxy.Event{Miner: miner})
func (w *Workers) OnLogin(e Event) {
if w == nil || e.Miner == nil {
return
@ -1550,6 +1552,8 @@ func (w *Workers) ResetMode(mode WorkersMode, miners []*Miner) {
}
// OnAccept updates the owning worker with the accepted share.
//
// workers.OnAccept(proxy.Event{Miner: miner, Diff: 100000})
func (w *Workers) OnAccept(e Event) {
if w == nil || e.Miner == nil {
return
@ -1573,6 +1577,8 @@ func (w *Workers) OnAccept(e Event) {
}
// OnReject updates the owning worker with the rejected share.
//
// workers.OnReject(proxy.Event{Miner: miner, Error: "Low difficulty share"})
func (w *Workers) OnReject(e Event) {
if w == nil || e.Miner == nil {
return
@ -1602,6 +1608,8 @@ func (w *Workers) OnClose(e Event) {
}
// List returns a snapshot of all workers.
//
// records := workers.List()
func (w *Workers) List() []WorkerRecord {
if w == nil {
return nil
@ -1616,6 +1624,8 @@ func (w *Workers) List() []WorkerRecord {
}
// Tick advances worker hash windows.
//
// workers.Tick()
func (w *Workers) Tick() {
if w == nil {
return

View file

@ -11,6 +11,7 @@ import (
// stats := proxy.NewStats()
// bus.Subscribe(proxy.EventAccept, stats.OnAccept)
// bus.Subscribe(proxy.EventReject, stats.OnReject)
// stats.Tick()
// _ = stats.Summary()
type Stats struct {
accepted atomic.Uint64