ax(mining): replace signature-restating comments with usage examples
Five comments in Manager were restating what the function signature
already showed ("returns X for Y"). Replace with concrete call
examples per AX principle 2 (Comments as Usage Examples).
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
ba4c5398b1
commit
f70e0b9f53
1 changed files with 8 additions and 5 deletions
|
|
@ -682,7 +682,8 @@ func (m *Manager) collectSingleMinerStats(miner Miner, minerType string, now tim
|
|||
})
|
||||
}
|
||||
|
||||
// GetMinerHashrateHistory returns the hashrate history for a specific miner.
|
||||
// points, err := manager.GetMinerHashrateHistory("xmrig")
|
||||
// for _, p := range points { fmt.Println(p.Timestamp, p.Hashrate) }
|
||||
func (m *Manager) GetMinerHashrateHistory(name string) ([]HashratePoint, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
|
@ -733,7 +734,8 @@ func (m *Manager) Stop() {
|
|||
})
|
||||
}
|
||||
|
||||
// GetMinerHistoricalStats returns historical stats from the database for a miner.
|
||||
// stats, err := manager.GetMinerHistoricalStats("xmrig")
|
||||
// if err == nil { fmt.Println(stats.AverageHashrate) }
|
||||
func (m *Manager) GetMinerHistoricalStats(minerName string) (*database.HashrateStats, error) {
|
||||
if !m.databaseEnabled {
|
||||
return nil, ErrDatabaseError("database persistence is disabled")
|
||||
|
|
@ -741,7 +743,7 @@ func (m *Manager) GetMinerHistoricalStats(minerName string) (*database.HashrateS
|
|||
return database.GetHashrateStats(minerName)
|
||||
}
|
||||
|
||||
// GetMinerHistoricalHashrate returns historical hashrate data from the database.
|
||||
// points, err := manager.GetMinerHistoricalHashrate("xmrig", time.Now().Add(-1*time.Hour), time.Now())
|
||||
func (m *Manager) GetMinerHistoricalHashrate(minerName string, since, until time.Time) ([]HashratePoint, error) {
|
||||
if !m.databaseEnabled {
|
||||
return nil, ErrDatabaseError("database persistence is disabled")
|
||||
|
|
@ -763,7 +765,8 @@ func (m *Manager) GetMinerHistoricalHashrate(minerName string, since, until time
|
|||
return points, nil
|
||||
}
|
||||
|
||||
// GetAllMinerHistoricalStats returns historical stats for all miners from the database.
|
||||
// allStats, err := manager.GetAllMinerHistoricalStats()
|
||||
// for _, s := range allStats { fmt.Println(s.MinerName, s.AverageHashrate) }
|
||||
func (m *Manager) GetAllMinerHistoricalStats() ([]database.HashrateStats, error) {
|
||||
if !m.databaseEnabled {
|
||||
return nil, ErrDatabaseError("database persistence is disabled")
|
||||
|
|
@ -771,7 +774,7 @@ func (m *Manager) GetAllMinerHistoricalStats() ([]database.HashrateStats, error)
|
|||
return database.GetAllMinerStats()
|
||||
}
|
||||
|
||||
// IsDatabaseEnabled returns whether database persistence is enabled.
|
||||
// if manager.IsDatabaseEnabled() { /* persist stats */ }
|
||||
func (m *Manager) IsDatabaseEnabled() bool {
|
||||
return m.databaseEnabled
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue