public void TestDoMining() { List <AlgorithmResult> algors = new List <AlgorithmResult>(); List <KeyValuePair <string, string> > paths = new List <KeyValuePair <string, string> >(); string json = System.IO.File.ReadAllText("miner.json"); MinerModel miners = JsonConvert.DeserializeObject <MinerModel>(json); AlgorithmResult algorX17 = new AlgorithmResult(); algorX17.name = "x17"; algorX17.Pool = PoolName.Zpool; algorX17.estimate_current = 600; algorX17.estimate_last24h = 700; algors.Add(algorX17); AlgorithmResult algorSkein = new AlgorithmResult(); algorSkein.name = "skein"; algorSkein.Pool = PoolName.Zpool; algorSkein.estimate_current = 500; algorSkein.estimate_last24h = 400; algors.Add(algorSkein); paths.Add(new KeyValuePair <string, string>("x17@zpool", "C:\\SoftwareMiner\\CryptoDredge_0.9.3\\start-BCD-bcd-zpool.bat")); miners.Path = paths; string bestAlgorAtPool; double bestPrice; (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners); MinerControl.DoMining(bestAlgorAtPool, miners.Path); System.Threading.Thread.Sleep(12000); AlgorithmResult algorNewGreater = new AlgorithmResult(); algorNewGreater.name = "skein"; algorNewGreater.Pool = PoolName.Zpool; algorNewGreater.estimate_current = 1000; algorNewGreater.estimate_last24h = 1000; algors.Add(algorNewGreater); (bestAlgorAtPool, bestPrice) = MinerControl.FindBestPrice(algors, true, miners); MinerControl.DoMining(bestAlgorAtPool, miners.Path); Assert.AreEqual(true, miners.SwapTime > 0); }
private static void DoMining() { string bestAlgor = ""; string bestCoin = ""; double bestAlgorPrice = 0; double bestCoinPrice = 0; try { (bestAlgor, bestAlgorPrice) = MinerControl.FindBestPrice(_algorsResult, true, _miners); (bestCoin, bestCoinPrice) = MinerControl.FindBestPrice(_coinsResult, _miners); if (bestAlgorPrice > bestCoinPrice) { if (MinerControl.DoMining(bestAlgor, _miners.Path)) { Console.WriteLine($"Start mining {bestAlgor} estimate {bestAlgorPrice} per day."); } else { Console.WriteLine($"Warning: Found best algor {bestAlgor} but not found miner config."); } } else { if (MinerControl.DoMining(bestCoin, _miners.Path)) { Console.WriteLine($"Start mining {bestCoin} estimate {bestCoinPrice} per day."); } else { Console.WriteLine($"Warning: Found best coin {bestCoin} but not found miner config."); } } } catch (Exception err) { Console.WriteLine($"Error : Can not start mining {bestAlgor} estimate {bestAlgorPrice} per day."); Console.WriteLine($"Error : {err.Message}. Error detail : {err.InnerException.Message}"); Console.WriteLine(); Console.WriteLine("Press Enter to exit."); Console.ReadLine(); System.Environment.Exit(-1); } }