ax(mining): replace prose accessor comments with usage examples in SimulatedMiner
AX Principle 2: comments that restate the type signature add zero information. Nine accessor methods converted from "Foo returns the bar" to concrete call examples. Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
463708aeab
commit
bd4f47cbba
1 changed files with 9 additions and 9 deletions
|
|
@ -82,7 +82,7 @@ func NewSimulatedMiner(config SimulatedMinerConfig) *SimulatedMiner {
|
|||
}
|
||||
}
|
||||
|
||||
// GetType returns the miner type identifier.
|
||||
// miner.GetType() == "simulated"
|
||||
func (m *SimulatedMiner) GetType() string {
|
||||
return m.MinerType
|
||||
}
|
||||
|
|
@ -303,22 +303,22 @@ func (m *SimulatedMiner) GetStats(ctx context.Context) (*PerformanceMetrics, err
|
|||
}, nil
|
||||
}
|
||||
|
||||
// GetName returns the miner's name.
|
||||
// miner.GetName() == "sim-xmrig-001"
|
||||
func (m *SimulatedMiner) GetName() string {
|
||||
return m.Name
|
||||
}
|
||||
|
||||
// GetPath returns a simulated path.
|
||||
// miner.GetPath() == "/simulated/miner"
|
||||
func (m *SimulatedMiner) GetPath() string {
|
||||
return m.Path
|
||||
}
|
||||
|
||||
// GetBinaryPath returns a simulated binary path.
|
||||
// miner.GetBinaryPath() == "/simulated/miner/sim-miner"
|
||||
func (m *SimulatedMiner) GetBinaryPath() string {
|
||||
return m.MinerBinary
|
||||
}
|
||||
|
||||
// CheckInstallation returns simulated installation details.
|
||||
// details, _ := miner.CheckInstallation() // always reports IsInstalled: true
|
||||
func (m *SimulatedMiner) CheckInstallation() (*InstallationDetails, error) {
|
||||
return &InstallationDetails{
|
||||
IsInstalled: true,
|
||||
|
|
@ -329,12 +329,12 @@ func (m *SimulatedMiner) CheckInstallation() (*InstallationDetails, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// GetLatestVersion returns a simulated version.
|
||||
// v, _ := miner.GetLatestVersion() // always "1.0.0-simulated", no network call
|
||||
func (m *SimulatedMiner) GetLatestVersion() (string, error) {
|
||||
return "1.0.0-simulated", nil
|
||||
}
|
||||
|
||||
// GetHashrateHistory returns the hashrate history.
|
||||
// points := miner.GetHashrateHistory() // snapshot of high-res window (last 5 min)
|
||||
func (m *SimulatedMiner) GetHashrateHistory() []HashratePoint {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
|
@ -344,7 +344,7 @@ func (m *SimulatedMiner) GetHashrateHistory() []HashratePoint {
|
|||
return result
|
||||
}
|
||||
|
||||
// AddHashratePoint adds a point to the history.
|
||||
// miner.AddHashratePoint(HashratePoint{Timestamp: now, Hashrate: 5000})
|
||||
func (m *SimulatedMiner) AddHashratePoint(point HashratePoint) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
|
@ -394,7 +394,7 @@ func (m *SimulatedMiner) ReduceHashrateHistory(now time.Time) {
|
|||
m.LowResHistory = newLowRes
|
||||
}
|
||||
|
||||
// GetLogs returns the simulated logs.
|
||||
// logs := miner.GetLogs() // capped at 100 lines, includes share accept/reject events
|
||||
func (m *SimulatedMiner) GetLogs() []string {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue