refactor(ax): improve public API examples
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
e523fd0740
commit
23623a97d3
4 changed files with 14 additions and 13 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue