diff --git a/config.go b/config.go index 760f1a9..a33bb71 100644 --- a/config.go +++ b/config.go @@ -2,11 +2,12 @@ package proxy // Config is the top-level proxy configuration. // -// cfg, result := proxy.LoadConfig("/etc/proxy.json") -// if !result.OK { -// return result.Error +// 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, // } -// cfg.Workers = proxy.WorkersByRigID type Config struct { Mode string `json:"mode"` // "nicehash" or "simple" Bind []BindAddr `json:"bind"` // listen addresses @@ -76,7 +77,7 @@ type HTTPConfig struct { // RateLimit controls per-IP connection throttling. // -// proxy.RateLimit{MaxConnectionsPerMinute: 30, BanDurationSeconds: 300} +// limiter := proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30, BanDurationSeconds: 300}) type RateLimit struct { MaxConnectionsPerMinute int `json:"max-connections-per-minute"` // 0 = disabled BanDurationSeconds int `json:"ban-duration"` // 0 = no ban diff --git a/events.go b/events.go index a662fa8..b9f0233 100644 --- a/events.go +++ b/events.go @@ -4,9 +4,11 @@ import "sync" // EventBus dispatches proxy lifecycle events to synchronous listeners. // -// bus := proxy.NewEventBus() -// bus.Subscribe(proxy.EventLogin, func(e proxy.Event) { _ = e.Miner.User() }) -// bus.Subscribe(proxy.EventAccept, stats.OnAccept) +// bus := proxy.NewEventBus() +// bus.Subscribe(proxy.EventLogin, func(e proxy.Event) { +// _ = e.Miner.User() +// }) +// bus.Subscribe(proxy.EventAccept, stats.OnAccept) type EventBus struct { listeners map[EventType][]EventHandler mu sync.RWMutex diff --git a/job.go b/job.go index 50b96c7..a05b08e 100644 --- a/job.go +++ b/job.go @@ -2,7 +2,12 @@ package proxy // Job holds one pool work unit and its metadata. // -// j := proxy.Job{Blob: strings.Repeat("0", 160), JobID: "4BiGm3/RgGQzgkTI", Target: "b88d0600", Algo: "cn/r"} +// j := proxy.Job{ +// Blob: strings.Repeat("0", 160), +// JobID: "4BiGm3/RgGQzgkTI", +// Target: "b88d0600", +// Algo: "cn/r", +// } // _ = j.BlobWithFixedByte(0x2A) // _ = j.DifficultyFromTarget() type Job struct { diff --git a/log/access.go b/log/access.go index 4261753..54e7a33 100644 --- a/log/access.go +++ b/log/access.go @@ -15,7 +15,7 @@ import ( // Line format (connect): 2026-04-04T12:00:00Z CONNECT // Line format (close): 2026-04-04T12:00:00Z CLOSE rx= tx= // -// al, result := log.NewAccessLog("/var/log/proxy-access.log") +// al := log.NewAccessLog("/var/log/proxy-access.log") // bus.Subscribe(proxy.EventLogin, al.OnLogin) // bus.Subscribe(proxy.EventClose, al.OnClose) type AccessLog struct { diff --git a/server.go b/server.go index f268d06..7f8efa4 100644 --- a/server.go +++ b/server.go @@ -11,7 +11,7 @@ import ( // proxy.BindAddr{Host: "0.0.0.0", Port: 3333, TLS: false}, // nil, // proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30}), -// onAccept, +// func(conn net.Conn, port uint16) { _ = conn; _ = port }, // ) // if result.OK { // srv.Start() diff --git a/worker.go b/worker.go index b0383ba..ff6cf7c 100644 --- a/worker.go +++ b/worker.go @@ -7,8 +7,8 @@ import ( // Workers tracks per-identity aggregates derived from miner login fields. // -// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus) -// workers.OnLogin(proxy.Event{Miner: miner}) +// workers := proxy.NewWorkers(proxy.WorkersByRigID, bus) +// workers.OnLogin(proxy.Event{Miner: &proxy.Miner{rigID: "rig-alpha", user: "WALLET", ip: "10.0.0.1"}}) type Workers struct { mode WorkersMode entries []WorkerRecord // ordered by first-seen (stable) @@ -20,7 +20,8 @@ type Workers struct { // WorkerRecord is the aggregate row returned by Workers.List(). // -// hr60 := record.Hashrate(60) +// record := proxy.WorkerRecord{Name: "rig-alpha"} +// _ = record.Hashrate(60) type WorkerRecord struct { Name string LastIP string