diff --git a/log/access.go b/log/access.go index da9252c..bdee5e3 100644 --- a/log/access.go +++ b/log/access.go @@ -13,7 +13,7 @@ import ( "dappco.re/go/core/proxy" ) -// AccessLog writes one CONNECT line on login and one CLOSE line on disconnect. +// AccessLog writes append-only connection lines. // // al := log.NewAccessLog("/var/log/proxy-access.log") // bus.Subscribe(proxy.EventLogin, al.OnLogin) @@ -25,7 +25,7 @@ type AccessLog struct { closed bool } -// NewAccessLog returns a lazy append-only logger for a single path. +// NewAccessLog opens the file lazily on first write. // // al := log.NewAccessLog("/var/log/proxy-access.log") func NewAccessLog(path string) *AccessLog { diff --git a/log/share.go b/log/share.go index d518fbc..cb8a1e6 100644 --- a/log/share.go +++ b/log/share.go @@ -9,7 +9,7 @@ import ( "dappco.re/go/core/proxy" ) -// ShareLog writes one ACCEPT line for accepted shares and one REJECT line for errors. +// ShareLog writes append-only share result lines. // // sl := log.NewShareLog("/var/log/proxy-shares.log") // bus.Subscribe(proxy.EventAccept, sl.OnAccept) @@ -21,7 +21,7 @@ type ShareLog struct { closed bool } -// NewShareLog returns a lazy append-only logger for share outcomes. +// NewShareLog opens the file lazily on first write. // // sl := log.NewShareLog("/var/log/proxy-shares.log") func NewShareLog(path string) *ShareLog { diff --git a/pool/client.go b/pool/client.go index 7d094d8..ad7dbcb 100644 --- a/pool/client.go +++ b/pool/client.go @@ -68,7 +68,7 @@ type jsonRPCErrorBody struct { Message string `json:"message"` } -// NewStratumClient stores the pool config and listener. +// NewStratumClient builds one outbound pool client. // // client := pool.NewStratumClient(proxy.PoolConfig{URL: "pool.lthn.io:3333", User: "WALLET", Pass: "x"}, listener) func NewStratumClient(cfg proxy.PoolConfig, listener StratumListener) *StratumClient { @@ -78,8 +78,9 @@ func NewStratumClient(cfg proxy.PoolConfig, listener StratumListener) *StratumCl } } -// Connect dials the pool. Applies TLS if cfg.TLS is true. +// Connect dials the pool and starts the read loop. // +// client := pool.NewStratumClient(proxy.PoolConfig{URL: "pool.lthn.io:3333", TLS: true}, listener) // errorValue := client.Connect() func (c *StratumClient) Connect() error { var connection net.Conn @@ -134,7 +135,7 @@ func (c *StratumClient) Connect() error { return nil } -// Login sends the stratum login request using cfg.User and cfg.Pass. +// Login sends the stratum login request using the configured wallet and password. // // client.Login() func (c *StratumClient) Login() { @@ -178,7 +179,7 @@ func (c *StratumClient) Submit(jobID string, nonce string, result string, algo s return requestID } -// Disconnect closes the connection cleanly. Triggers OnDisconnect on the listener. +// Disconnect closes the connection and emits one disconnect callback. // // client.Disconnect() func (c *StratumClient) Disconnect() { diff --git a/pool/strategy.go b/pool/strategy.go index 0224bf2..5d881ef 100644 --- a/pool/strategy.go +++ b/pool/strategy.go @@ -39,9 +39,9 @@ type Strategy interface { IsActive() bool } -// NewStrategyFactory captures the pool list and retry settings for later mapper creation. +// NewStrategyFactory captures the live pool list and retry settings. // -// factory := pool.NewStrategyFactory(cfg) +// factory := pool.NewStrategyFactory(proxy.Config{Pools: []proxy.PoolConfig{{URL: "pool.lthn.io:3333", Enabled: true}}}) func NewStrategyFactory(cfg *proxy.Config) StrategyFactory { return func(listener StratumListener) Strategy { if cfg == nil { @@ -51,9 +51,9 @@ func NewStrategyFactory(cfg *proxy.Config) StrategyFactory { } } -// NewFailoverStrategy stores the pool list and listener. +// NewFailoverStrategy builds one failover client stack. // -// strategy := pool.NewFailoverStrategy(cfg.Pools, listener, cfg) +// strategy := pool.NewFailoverStrategy([]proxy.PoolConfig{{URL: "pool.lthn.io:3333", Enabled: true}}, listener, cfg) func NewFailoverStrategy(pools []proxy.PoolConfig, listener StratumListener, cfg *proxy.Config) *FailoverStrategy { return &FailoverStrategy{ pools: append([]proxy.PoolConfig(nil), pools...), @@ -62,7 +62,7 @@ func NewFailoverStrategy(pools []proxy.PoolConfig, listener StratumListener, cfg } } -// Connect dials the current pool. On failure, advances to the next pool. +// Connect dials the first enabled pool and rotates through fallbacks on failure. // // strategy.Connect() func (s *FailoverStrategy) Connect() {