diff --git a/core_impl.go b/core_impl.go index f7a8246..2bef061 100644 --- a/core_impl.go +++ b/core_impl.go @@ -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)} } diff --git a/state_impl.go b/state_impl.go index dfd185f..396a5c0 100644 --- a/state_impl.go +++ b/state_impl.go @@ -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 diff --git a/stats.go b/stats.go index 35fd897..9186c27 100644 --- a/stats.go +++ b/stats.go @@ -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