From 114dd900818f6a3cdeb9aaf8971e4993f207b93f Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 2 Apr 2026 10:13:57 +0100 Subject: [PATCH] ax(mining): replace prose comments with usage examples in simulated_miner.go 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 --- pkg/mining/simulated_miner.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/mining/simulated_miner.go b/pkg/mining/simulated_miner.go index a94fe26..20a819b 100644 --- a/pkg/mining/simulated_miner.go +++ b/pkg/mining/simulated_miner.go @@ -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",