public void ImportMiner(string minerFile) { var fileName = Path.GetFileName(minerFile)?.ToLower(); if (fileName == null) { return; } if (!Consts.Miners.Contains(fileName)) { throw new NotSupportedException("The specified file is not a supported miner"); } var miner = Miners.FirstOrDefault(m => m.Path.Equals(minerFile, StringComparison.InvariantCultureIgnoreCase)); if (miner != null) { return; } miner = new Miner { Path = minerFile }; Miners.Add(miner); }
/// <summary> /// Miner indítása /// </summary> /// <returns></returns> public bool StartMiner() { bool success = false; if (_pools != null && _pools.Count > 0) { if (MinerType == MinerType.GPU) { switch (Algorithm) { case (int)SupportedAlgos.CryptoNight: default: Stratum.Stratum mainPool = createStratumFromPoolSettings(_pools, (int)SupportedAlgos.CryptoNight); if (mainPool != null && mainPool is CryptoNightStratum) { foreach (var device in Devices.Where(x => x.IsEnabled)) { for (int i = 0; i < device.Threads; ++i) { OpenCLCryptoNightMiner miner = null; try { miner = new OpenCLCryptoNightMiner(device); miner.Start(mainPool as CryptoNightStratum, device.Intensity, device.WorkSize, true); Miners.Add(miner); } catch (Exception ex) { Messenger.Default.Send <MinerOutputMessage>(new MinerOutputMessage() { OutputText = $"Faild to start GPU miner on Device# {device.ADLAdapterIndex} Thread# {i+1}", Exception = ex, IsError = true }); } } } success = true; } break; } } else if (MinerType == MinerType.CPU) { exeMinerManager = new ExeManager(ApplicationPath, ExeFileName); string minerParameter = generateMinerCall(); MinerThread = new Thread(() => exeMinerManager.ExecuteResource(minerParameter)); MinerThread.Start(); success = true; } } else { Messenger.Default.Send <MinerOutputMessage>(new MinerOutputMessage() { OutputText = "WARNING: No main pool selected." }); } return(success); }
public void SaveChanges(Miner miner) { SaveChanges <Miner>(miner); for (int i = 0; i < Miners.Count; i++) { if (Miners[i].Identifier == miner.Identifier) { Miners.RemoveAt(i); Miners.Insert(i, miner); return; } } Miners.Add(miner); }
private void MinerBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { bool?modified = false; using (var context = new Context()) { foreach (var miner in context.Miners) { if (!Miners.Any(c => c.Id == miner.Id)) { Miners.Add(miner); modified = true; } } } e.Result = modified; }
public void GenerateUsersAndTransactions() { Random rnd = new Random(); //Generates Users for (var i = 0; i < 1000; i++) { var name = $"user{i}"; var userHash = HashFunction.GetHash(name); var balance = rnd.Next(100, 1000); Users.Add(new User(name, userHash, balance)); } //Generates Miners for (var i = 0; i < 10; i++) { var name = $"miner{i}"; var userHash = HashFunction.GetHash(name); var balance = 0; Miners.Add(new User(name, userHash, balance)); } //Generates random x number transactions for (var i = 0; i < 10000; i++) { var senderIndex = rnd.Next(Users.Count); var receiverIndex = rnd.Next(Users.Count); //If receiver is same as sender while (receiverIndex == senderIndex) { receiverIndex = rnd.Next(Users.Count); } var amount = rnd.Next(10, 250); var sender = Users[senderIndex]; var receiver = Users[receiverIndex]; CreateTransaction(new Transaction(sender, receiver, amount)); } }
public bool AddMiner(IMiner miner) { bool toSave = false; ICoinConfigurer mainCoinConfigurer = miner.MainCoin.SettingsScreen; ICoinConfigurer dualCoinConfigurer = null; if (miner.DualMining) { dualCoinConfigurer = miner.DualCoin.SettingsScreen; } MinerData newMiner = new MinerData(); newMiner.Id = miner.Id; newMiner.Name = miner.Name; newMiner.Algorithm = miner.MainCoin.Algorithm.Name; //newMiner.BATFileName =""; newMiner.MainCoin = miner.MainCoin.Name; newMiner.MainCoinPool = mainCoinConfigurer.Pool; newMiner.MainCoinWallet = mainCoinConfigurer.Wallet; newMiner.MainCoinPassword = mainCoinConfigurer.Password; newMiner.MainCoinPoolAccount = mainCoinConfigurer.PoolAccount; newMiner.DualMining = miner.DualMining; newMiner.MinerGpuType = miner.MinerGpuType; newMiner.HashRate = miner.HashRate; if (miner.DualMining) { newMiner.DualCoin = miner.DualCoin.Name; newMiner.DualCoinPool = dualCoinConfigurer.Pool; newMiner.DualCoinWallet = dualCoinConfigurer.Wallet; newMiner.DualCoinPoolAccount = dualCoinConfigurer.PoolAccount; } //minerprograms foreach (IMinerProgram item in miner.MinerPrograms) { MinerScript script = new MinerScript(); script.BATfile = item.BATFILE; script.ProgramType = item.Type; script.AutomaticScriptGeneration = item.AutomaticScriptGeneration; script.MiningIntensity = item.MiningIntensity; newMiner.MinerScripts.Add(script); } //if a similar type is alredy present, them remove it List <int> removeIds = new List <int>(); int i = 0; foreach (MinerData item in Miners) { if (item.Id == miner.Id) { removeIds.Add(i); } i++; } foreach (int j in removeIds) { Miners.RemoveAt(j); } Miners.Add(newMiner); toSave = true; return(toSave); }