Enchantrix/pkg/pool/pool.go
google-labs-jules[bot] 47e12b1875 feat: Implement xmrig-proxy functionality
This commit introduces the initial implementation of the xmrig-proxy functionality.

It includes:
- A new `proxy` command to the CLI to start the proxy.
- A new `pkg/proxy` package to encapsulate the core proxy logic.
- A mock proxy service that simulates workers connecting.
- The initial implementation of the XMRig Proxy API, with the `/` and `/workers.json` endpoints.
2025-10-31 05:03:46 +00:00

44 lines
740 B
Go

package pool
import (
"github.com/Snider/Enchantrix/pkg/miner"
"time"
)
type PoolClient struct {
URL string
User string
Pass string
JobQueue *miner.JobQueue
stopChannel chan struct{}
}
func New(url, user, pass string, jobQueue *miner.JobQueue) *PoolClient {
return &PoolClient{
URL: url,
User: user,
Pass: pass,
JobQueue: jobQueue,
stopChannel: make(chan struct{}),
}
}
func (p *PoolClient) Start() {
go func() {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
p.JobQueue.Set(miner.NewMockJob())
case <-p.stopChannel:
return
}
}
}()
}
func (p *PoolClient) Stop() {
close(p.stopChannel)
}