ax(mining): replace prose comments with usage examples in simulated_miner.go
Some checks are pending
Security Scan / security (push) Waiting to run
Test / test (push) Waiting to run

AX Principle 2: comments must show concrete usage, not restate the signature.
Four functions (NewSimulatedMiner, Stop, GetStats, SimulatedMinerPresets) had
"X does Y" prose descriptions replaced with call-site examples.

Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
Claude 2026-04-02 10:13:57 +01:00
parent 6b22f2b60d
commit 114dd90081
No known key found for this signature in database
GPG key ID: AF404715446AEB41

View file

@ -52,7 +52,8 @@ type SimulatedMinerConfig struct {
Difficulty int // Base difficulty
}
// NewSimulatedMiner creates a new simulated miner instance.
// miner := NewSimulatedMiner(SimulatedMinerConfig{Name: "sim-001", Algorithm: "rx/0", BaseHashrate: 5000})
// miner.Start(ctx)
func NewSimulatedMiner(config SimulatedMinerConfig) *SimulatedMiner {
if config.Variance <= 0 {
config.Variance = 0.1 // Default 10% variance
@ -125,7 +126,7 @@ func (m *SimulatedMiner) Start(config *Config) error {
return nil
}
// Stop stops the simulated miner.
// if err := miner.Stop(); err != nil { /* miner was not running */ }
func (m *SimulatedMiner) Stop() error {
m.mu.Lock()
defer m.mu.Unlock()
@ -264,7 +265,8 @@ func (m *SimulatedMiner) simulateShare() {
}
}
// GetStats returns current performance metrics.
// metrics, err := miner.GetStats(ctx)
// fmt.Printf("hashrate: %d H/s, shares: %d\n", metrics.Hashrate, metrics.Shares)
func (m *SimulatedMiner) GetStats(ctx context.Context) (*PerformanceMetrics, error) {
m.mu.RLock()
defer m.mu.RUnlock()
@ -417,7 +419,8 @@ func (m *SimulatedMiner) WriteStdin(input string) error {
return nil
}
// SimulatedMinerPresets provides common presets for simulated miners.
// miner := NewSimulatedMiner(SimulatedMinerPresets["cpu-medium"])
// miner := NewSimulatedMiner(SimulatedMinerPresets["gpu-ethash"])
var SimulatedMinerPresets = map[string]SimulatedMinerConfig{
"cpu-low": {
Algorithm: "rx/0",