Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
46 lines
1.0 KiB
Go
46 lines
1.0 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.mu.Unlock()
|
|
c.mergeAtlasSkipsIntoPolicy()
|
|
}
|
|
|
|
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()
|
|
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)
|
|
}
|
|
}
|