Files
AetherForge/agent/client/atlas_policy.go
AetherForge 5c6913dc5f
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Validate and integrate fleet intelligence features
Fix atlas skip merge under lock, tolerate post-auth WS frames in tests,
and harden test-suite npm invocation on Windows.
2026-06-07 02:49:35 -07:00

50 lines
1.1 KiB
Go

package client
import (
"crypto-miner-agent/miner"
)
// AtlasSkip is a fleet-learned hard skip from the failure atlas.
type AtlasSkip struct {
Tier string `json:"tier"`
Condition string `json:"condition"`
Reason string `json:"reason"`
}
func (c *AgentClient) applyAtlasSkips(skips []AtlasSkip) {
c.mu.Lock()
c.atlasSkips = append([]AtlasSkip(nil), skips...)
c.mergeAtlasSkipsIntoPolicyLocked()
c.mu.Unlock()
}
func (c *AgentClient) atlasSkipsSnapshot() []AtlasSkip {
c.mu.Lock()
defer c.mu.Unlock()
return append([]AtlasSkip(nil), c.atlasSkips...)
}
func (c *AgentClient) mergeAtlasSkipsIntoPolicy() {
c.mu.Lock()
defer c.mu.Unlock()
c.mergeAtlasSkipsIntoPolicyLocked()
}
func (c *AgentClient) mergeAtlasSkipsIntoPolicyLocked() {
if len(c.atlasSkips) == 0 {
return
}
have := make(map[miner.LOTLTier]bool, len(c.tierPolicy.SkipTiers))
for _, t := range c.tierPolicy.SkipTiers {
have[t] = true
}
for _, skip := range c.atlasSkips {
tier := miner.LOTLTier(skip.Tier)
if tier == "" || have[tier] {
continue
}
have[tier] = true
c.tierPolicy.SkipTiers = append(c.tierPolicy.SkipTiers, tier)
}
}