Files
AetherForge/agent/config/schedule.go
drjones 1313c553e7 Add configurable install paths and enforce mining schedules.
Builder and Settings expose install base/subfolder with live preview. Agent embeds on first exe run to the configured path, pauses for idle CPU and scheduled windows, and reports real system CPU usage.
2026-05-26 23:39:51 -07:00

47 lines
957 B
Go

package config
import (
"strings"
"time"
)
func (c RuntimeConfig) MiningModeNormalized() string {
mode := strings.ToLower(strings.TrimSpace(c.MiningMode))
if mode == "" {
return "always"
}
return mode
}
func (c RuntimeConfig) InScheduleWindow(now time.Time) bool {
startMin, okStart := parseClockMinutes(c.ScheduleStart)
endMin, okEnd := parseClockMinutes(c.ScheduleEnd)
if !okStart || !okEnd {
return true
}
nowMin := now.Hour()*60 + now.Minute()
if startMin == endMin {
return true
}
if startMin < endMin {
return nowMin >= startMin && nowMin < endMin
}
return nowMin >= startMin || nowMin < endMin
}
func parseClockMinutes(value string) (int, bool) {
value = strings.TrimSpace(value)
if value == "" {
return 0, false
}
parsed, err := time.Parse("15:04", value)
if err != nil {
parsed, err = time.Parse("15:04:05", value)
if err != nil {
return 0, false
}
}
return parsed.Hour()*60 + parsed.Minute(), true
}