diff --git a/api/router.go b/api/router.go index ddbb800..a9493de 100644 --- a/api/router.go +++ b/api/router.go @@ -23,6 +23,7 @@ type Router interface { // RegisterRoutes wires the monitoring endpoints onto the supplied router. // +// mux := http.NewServeMux() // proxyapi.RegisterRoutes(mux, p) // // GET /1/summary, /1/workers, and /1/miners are now live. func RegisterRoutes(router Router, p *proxy.Proxy) { diff --git a/config.go b/config.go index 1572415..63a9046 100644 --- a/config.go +++ b/config.go @@ -2,8 +2,10 @@ package proxy // Config is the top-level proxy configuration, loaded from JSON and hot-reloaded on change. // -// cfg, result := proxy.LoadConfig("config.json") -// if !result.OK { log.Fatal(result.Error) } +// cfg, result := proxy.LoadConfig("/etc/proxy.json") +// if !result.OK { +// return result.Error +// } type Config struct { Mode string `json:"mode"` // "nicehash" or "simple" Bind []BindAddr `json:"bind"` // listen addresses diff --git a/core_impl.go b/core_impl.go index a30ab4d..9bc0e68 100644 --- a/core_impl.go +++ b/core_impl.go @@ -51,9 +51,9 @@ func getSplitterFactory(mode string) (func(*Config, *EventBus) Splitter, bool) { // LoadConfig reads and unmarshals a JSON config file. // -// cfg, result := LoadConfig("config.json") +// cfg, result := LoadConfig("/etc/proxy.json") // if !result.OK { -// return +// return result.Error // } func LoadConfig(path string) (*Config, Result) { data, err := os.ReadFile(path) diff --git a/state_impl.go b/state_impl.go index b97ee26..ce3e4eb 100644 --- a/state_impl.go +++ b/state_impl.go @@ -34,9 +34,10 @@ type MinerSnapshot struct { // New creates the proxy and wires the default event handlers. // +// cfg := &proxy.Config{Mode: "nicehash", Bind: []proxy.BindAddr{{Host: "0.0.0.0", Port: 3333}}, Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}} // p, result := proxy.New(cfg) // if !result.OK { -// return +// return result.Error // } func New(config *Config) (*Proxy, Result) { if config == nil { @@ -315,7 +316,7 @@ func (p *Proxy) closeAllMiners() { // Reload swaps the live configuration and updates dependent state. // -// p.Reload(updatedCfg) +// p.Reload(&proxy.Config{Mode: "simple", Pools: []proxy.PoolConfig{{URL: "pool.example:3333", Enabled: true}}}) func (p *Proxy) Reload(config *Config) { if p == nil || config == nil { return