diff --git a/pkg/database/interface.go b/pkg/database/interface.go index 0312687..c709b3d 100644 --- a/pkg/database/interface.go +++ b/pkg/database/interface.go @@ -8,23 +8,24 @@ import ( // HashrateStore defines the interface for hashrate data persistence. // This interface allows for dependency injection and easier testing. type HashrateStore interface { - // InsertHashratePoint stores a hashrate measurement. - // If ctx is nil, a default timeout will be used. + // store.InsertHashratePoint(ctx, "xmrig", "xmrig", HashratePoint{Timestamp: time.Now(), Hashrate: 1234}, ResolutionHigh) InsertHashratePoint(ctx context.Context, minerName, minerType string, point HashratePoint, resolution Resolution) error - // GetHashrateHistory retrieves hashrate history for a miner within a time range. + // points, err := store.GetHashrateHistory("xmrig", ResolutionHigh, time.Now().Add(-time.Hour), time.Now()) GetHashrateHistory(minerName string, resolution Resolution, since, until time.Time) ([]HashratePoint, error) - // GetHashrateStats retrieves aggregated statistics for a specific miner. + // stats, err := store.GetHashrateStats("xmrig") + // if stats != nil { log.Printf("avg: %d H/s", stats.AverageRate) } GetHashrateStats(minerName string) (*HashrateStats, error) - // GetAllMinerStats retrieves statistics for all miners. + // allStats, err := store.GetAllMinerStats() + // for _, stats := range allStats { log.Printf("%s avg: %d H/s", stats.MinerName, stats.AverageRate) } GetAllMinerStats() ([]HashrateStats, error) - // Cleanup removes old data based on retention settings. + // store.Cleanup(30) // remove data older than 30 days Cleanup(retentionDays int) error - // Close closes the store and releases resources. + // store.Close() Close() error }