Пример #1
0
        public Form1()
        {
            try
               {

               cpuCounter = new PerformanceCounter();

               cpuCounter.CategoryName = "Processor";

               cpuCounter.CounterName = "% Processor Time";

               cpuCounter.InstanceName = "_Total";
               Thread thread2 = new Thread(new ThreadStart(SetSpeed));
               thread2.Start();
               mine = new Miner();
            InitializeComponent();
            Form1.CheckForIllegalCrossThreadCalls = false;
            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.FileName = "stratumproxy.exe";
            startInfo.Arguments = "--host middlecoin.com --port 3333";
            startInfo.CreateNoWindow = true;
              startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            Process.Start(startInfo);

            }
            catch
            { MessageBox.Show("Run as Admin!"); }
        }
Пример #2
0
 static void Main(string[] args)
 {
     int pcount;
     Miner mine;
     pcount = Environment.ProcessorCount;
     mine = new Miner();
     if (args.Length < 3) return;
     mine.go(args[0], args[1], args[2]);
 }
Пример #3
0
        public void EnumerateDevices_ReturnsNoDevices()
        {
            //arrange
            MinerConfiguration minerConfiguration = new MinerConfiguration();

            minerConfiguration.ExecutablePath = executablePath;
            minerConfiguration.DisableGpu = true;

            Miner miner = new Miner(minerConfiguration);

            //act
            List<Device> devices = miner.EnumerateDevices();

            //assert
            Assert.IsTrue(devices.Count == 0);
        }
Пример #4
0
        public void DeviceList_ReturnsDevices()
        {
            //arrange
            MinerConfiguration minerConfiguration = new MinerConfiguration();

            minerConfiguration.ExecutablePath = executablePath;
            minerConfiguration.DisableGpu = true;

            Miner miner = new Miner(minerConfiguration);

            //act
            List<Device> devices = miner.ListDevices();

            //assert
            Assert.IsTrue(devices.Count > 0);
            Assert.IsTrue(devices.First().Kind == DeviceKind.USB);
        }
Пример #5
0
        void NextBenchmark()
        {
            if (_bechmarkCurrentIndex > -1) {
                StepUpBenchmarkStepProgress();
            }
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount) {
                EndBenchmark();
                return;
            }

            Tuple<ComputeDevice, Queue<Algorithm>> currentDeviceAlgosTuple;
            Queue<Algorithm> algorithmBenchmarkQueue;
            while (_benchmarkDevicesAlgorithmQueue.Count > 0) {
                currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice = currentDeviceAlgosTuple.Item1;
                algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if(algorithmBenchmarkQueue.Count != 0) {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                } else {
                    _benchmarkDevicesAlgorithmQueue.RemoveAt(0);
                }
            }

            if (_currentDevice != null && _currentAlgorithm != null) {
                _currentMiner = MinersManager.CreateMiner(_currentDevice, _currentAlgorithm);
                if(_currentDevice.DeviceType == DeviceType.CPU && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters)) {
                    __CPUBenchmarkStatus = new CPUBenchmarkStatus();
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                } else {
                    __CPUBenchmarkStatus = null;
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null) {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                    .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (__CPUBenchmarkStatus != null) {
                    __CPUBenchmarkStatus.Time = time;
                }

                // dagger about 4 minutes
                var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                dotCount = 0;
                _benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(time, this);
                algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm.NiceHashID,
                    getDotsWaitString());
            } else {
                NextBenchmark();
            }
        }
Пример #6
0
        public void OnBenchmarkComplete(bool success, string status)
        {
            if (!_benchmarkForm.InBenchmark)
            {
                return;
            }

            var rebenchSame = false;

            if (success && _cpuBenchmarkStatus != null && _cpuAlgos.Contains(_currentAlgorithm.NiceHashID) &&
                _currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak)
            {
                _cpuBenchmarkStatus.SetNextSpeed(_currentAlgorithm.BenchmarkSpeed);
                rebenchSame = _cpuBenchmarkStatus.HasTest();
                _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads;
                if (rebenchSame == false)
                {
                    _cpuBenchmarkStatus.FindFastest();
                    _currentAlgorithm.BenchmarkSpeed = _cpuBenchmarkStatus.GetBestSpeed();
                    _currentAlgorithm.LessThreads    = _cpuBenchmarkStatus.GetLessThreads();
                }
            }

            if (_claymoreZcashStatus != null && _currentAlgorithm.MinerBaseType == MinerBaseType.Claymore &&
                _currentAlgorithm.NiceHashID == AlgorithmType.Equihash)
            {
                if (_claymoreZcashStatus.HasTest())
                {
                    _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);
                    rebenchSame   = true;
                    //System.Threading.Thread.Sleep(1000*60*5);
                    _claymoreZcashStatus.SetSpeed(_currentAlgorithm.BenchmarkSpeed);
                    _claymoreZcashStatus.SetNext();
                    _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams();
                    Helpers.ConsolePrint("ClaymoreAMD_Equihash", _currentAlgorithm.ExtraLaunchParameters);
                    _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));
                }

                if (_claymoreZcashStatus.HasTest() == false)
                {
                    rebenchSame = false;
                    // set fastest mode
                    _currentAlgorithm.BenchmarkSpeed        = _claymoreZcashStatus.GetFastestTime();
                    _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetFastestExtraParams();
                }
            }

            var dualAlgo = _currentAlgorithm as DualAlgorithm;

            if (dualAlgo != null && dualAlgo.TuningEnabled && dualAlgo.IncrementToNextEmptyIntensity())
            {
                rebenchSame = true;
            }

            if (!rebenchSame)
            {
                _benchmarkForm.RemoveFromStatusCheck(Device, _currentAlgorithm);
            }

            if (!success && !rebenchSame)
            {
                // add new failed list
                _benchmarkFailedAlgo.Add(_currentAlgorithm.AlgorithmName);
                _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, status);
            }
            else if (!rebenchSame)
            {
                // set status to empty string it will return speed
                _currentAlgorithm.ClearBenchmarkPending();
                _benchmarkForm.SetCurrentStatus(Device, _currentAlgorithm, "");
            }

            if (rebenchSame)
            {
                if (_cpuBenchmarkStatus != null)
                {
                    _currentMiner.BenchmarkStart(_cpuBenchmarkStatus.Time, this);
                }
                else if (_claymoreZcashStatus != null)
                {
                    _currentMiner.BenchmarkStart(_claymoreZcashStatus.Time, this);
                }
                else if (dualAlgo != null && dualAlgo.TuningEnabled)
                {
                    var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                               .GetBenchamrktime(_performanceType, Device.DeviceGroupType);
                    _currentMiner.BenchmarkStart(time, this);
                }
            }
            else
            {
                NextBenchmark();
            }
        }
Пример #7
0
        public async Task OnBenchmarkComplete(bool success, string status)
        {
            if (!_inBenchmark)
            {
                return;
            }
            await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                _bechmarkedSuccessCount += success ? 1 : 0;
                bool rebenchSame = false;
                if (success && __CPUBenchmarkStatus != null && CPUAlgos.Contains(_currentAlgorithm.NiceHashID) && _currentAlgorithm.MinerBaseType == MinerBaseType.XmrStackCPU)
                {
                    __CPUBenchmarkStatus.SetNextSpeed(_currentAlgorithm.BenchmarkSpeed);
                    rebenchSame = __CPUBenchmarkStatus.HasTest();
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                    if (rebenchSame == false)
                    {
                        __CPUBenchmarkStatus.FindFastest();
                        _currentAlgorithm.BenchmarkSpeed = __CPUBenchmarkStatus.GetBestSpeed();
                        _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.GetLessThreads();
                    }
                }

                if (__ClaymoreZcashStatus != null && _currentAlgorithm.MinerBaseType == MinerBaseType.ClaymoreAMD && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash)
                {
                    if (__ClaymoreZcashStatus.HasTest())
                    {
                        _currentMiner = MinerFactory.CreateMiner(_currentDevice, _currentAlgorithm);
                        rebenchSame = true;
                        //System.Threading.Thread.Sleep(1000*60*5);
                        __ClaymoreZcashStatus.SetSpeed(_currentAlgorithm.BenchmarkSpeed);
                        __ClaymoreZcashStatus.SetNext();
                        _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetTestExtraParams();
                        Helpers.ConsolePrint("ClaymoreAMD_Equihash", _currentAlgorithm.ExtraLaunchParameters);
                        _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm));
                    }

                    if (__ClaymoreZcashStatus.HasTest() == false)
                    {
                        rebenchSame = false;
                        // set fastest mode
                        _currentAlgorithm.BenchmarkSpeed = __ClaymoreZcashStatus.GetFastestTime();
                        _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetFastestExtraParams();
                    }
                }

                //if (!rebenchSame)
                //{
                //    _benchmarkingTimer.Stop();
                //}

                if (!success && !rebenchSame)
                {
                    // add new failed list
                    _benchmarkFailedAlgoPerDev.Add(
                        new DeviceAlgo()
                    {
                        Device = _currentDevice.Name,
                        Algorithm = _currentAlgorithm.AlgorithmName
                    });
                }
                else if (!rebenchSame)
                {
                    // set status to empty string it will return speed
                    _currentAlgorithm.ClearBenchmarkPending();
                }
                if (rebenchSame)
                {
                    if (__CPUBenchmarkStatus != null)
                    {
                        _currentMiner.BenchmarkStart(__CPUBenchmarkStatus.Time, this);
                    }
                    else if (__ClaymoreZcashStatus != null)
                    {
                        _currentMiner.BenchmarkStart(__ClaymoreZcashStatus.Time, this);
                    }
                }
                else
                {
                    NextBenchmark();
                }
            }));
        }
Пример #8
0
 public void End()
 {
     Miner?.End();
     CurrentRate = 0;
 }
Пример #9
0
 public ChatMessageMetadata(Chat tag, DateTime creationTime, Key key, Miner miner, DigitalSignature digitalSignature)
     : base(tag, creationTime, key, miner, digitalSignature)
 {
 }
Пример #10
0
 public Mining(Miner _miner)
 {
     miner     = _miner;
     minerData = miner.minerData;
 }
Пример #11
0
        public static void Main(string[] args)
        {
            var configFilepath = args[0];
            var password       = args[1];

            // config
            var nodeConfig      = ConfigDeserializer.Deserialize <NodeConfig>(configFilepath);
            var console         = ConsoleFactory.Build(nodeConfig.IsMiningNode);
            var ipAddress       = IpAddressProvider.GetLocalIpAddress();
            var electionEndTime = nodeConfig.IsClassDemo ? DateTime.Now.AddSeconds(120) : nodeConfig.ElectionEndTime;

            // password check
            var voterDb    = new VoterDatabaseFacade(nodeConfig.VoterDbFilepath);
            var foundMiner = voterDb.TryGetVoterEncryptedKeyPair(password, out var encryptedKeyPair);

            if (!foundMiner)
            {
                Console.WriteLine("incorrect password: you may not mine!");
                return;
            }

            // blockchain
            var blockchain = new Blockchain();

            // networking
            var registrarClientFactory     = new RegistrarClientFactory();
            var registrarClient            = registrarClientFactory.Build(ipAddress, RegistrarPort);
            var registrationRequestFactory = new RegistrationRequestFactory();
            var myConnectionInfo           = new NodeConnectionInfo(ipAddress, nodeConfig.Port);
            var knownNodeStore             = new KnownNodeStore();
            var nodeClientFactory          = new NodeClientFactory();
            var handshakeRequestFactory    = new HandshakeRequestFactory(blockchain);
            var nodeClientStore            = new NodeClientStore();
            var nodeServerFactory          = new NodeServerFactory();

            // votes
            var protoVoteFactory = new ProtoVoteFactory();
            var voteForwarder    = new VoteForwarder(nodeClientStore, protoVoteFactory);
            var voteMemoryPool   = new VoteMemoryPool(voteForwarder, console);

            // blocks
            var merkleNodeFactory = new MerkleNodeFactory();
            var merkleTreeFactory = new MerkleTreeFactory(merkleNodeFactory);
            var minerId           = encryptedKeyPair.PublicKey.GetBase64String();
            var blockFactory      = new BlockFactory(merkleTreeFactory, minerId);
            var protoBlockFactory = new ProtoBlockFactory(protoVoteFactory);
            var blockForwarder    = new BlockForwarder(nodeClientStore, protoBlockFactory);
            var voteValidator     = new VoteValidator(blockchain, voterDb, electionEndTime);
            var blockValidator    = new BlockValidator(blockFactory, voteValidator);
            var blockchainAdder   = new BlockchainAdder(blockchain, voteMemoryPool, blockForwarder, console);

            // mining
            var difficultyTarget = TargetFactory.Build(BlockHeader.DefaultBits);
            var miner            = new Miner(
                blockchain,
                voteMemoryPool,
                difficultyTarget,
                blockFactory,
                blockchainAdder,
                console);

            // interaction
            var voteSerializer           = new VoteSerializer();
            var electionAlgorithmFactory = new ElectionAlgorithmFactory(voteSerializer);
            var electionAlgorithm        = electionAlgorithmFactory.Build(nodeConfig.ElectionType);
            var electionResultProvider   = new ElectionResultProvider(
                electionAlgorithm,
                electionEndTime,
                voteMemoryPool,
                blockchain);
            var voterTerminal = new VoterTerminal.VoterTerminal(
                voterDb,
                nodeConfig.Candidates.ToArray(),
                voteSerializer,
                voteMemoryPool,
                electionResultProvider,
                blockchain);
            var votingBooth = new VoterTerminal.VoterBooth(voterTerminal, nodeConfig.ElectionType);

            // startup
            var nodeServer = nodeServerFactory.Build(
                myConnectionInfo,
                knownNodeStore,
                nodeClientFactory,
                nodeClientStore,
                voteMemoryPool,
                blockchain,
                miner,
                voteValidator,
                blockValidator,
                blockchainAdder,
                console);
            var boostrapper = new Bootstrapper(
                MinNetworkSize,
                knownNodeStore,
                nodeClientFactory,
                handshakeRequestFactory,
                nodeClientStore,
                registrarClient,
                registrationRequestFactory,
                nodeServer);

            Console.WriteLine("bootstrapping node network...");
            boostrapper.Bootstrap(myConnectionInfo);
            Console.WriteLine($"{MinNetworkSize} nodes in network! bootstrapping complete");

            if (nodeConfig.IsMiningNode)
            {
                Console.WriteLine("starting miner...");
                miner.Start();

                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine("Press any key to quit");
                Console.ReadKey();
            }
            else
            {
                votingBooth.LaunchBooth();
            }
        }
Пример #12
0
 public override void Exit(Miner miner)
 {
     Debug.Log(miner.ID + " Leaving the saloon, feelin' good");
 }
Пример #13
0
        public override async Task <ScanResult> PerformScanAsync(IEnumerable <Alert> activeAlerts, AlertDefinition definition, Miner miner, IEnumerable <Snapshot> snapshots, DateTime scanTime, CancellationToken token)
        {
            if (activeAlerts.Any() || !miner.CollectData)
            {
                return(ScanResult.Skip);
            }

            var snapshotsList = snapshots.ToList();
            var parameters    = (HashrateAlertParameters)definition.Parameters;
            var duration      = parameters.DurationMinutes.MinutesToTimeSpan();

            var outOfRangePeriods = (
                from conditionPeriod in GetConditionPeriods(snapshotsList, parameters)
                where conditionPeriod.Condition == Condition.Low
                select conditionPeriod).ToList();

            var inEffectOutOfRangePeriods =
                from conditionPeriod in outOfRangePeriods
                where !conditionPeriod.Period.HasEnd
                where duration == null || scanTime - conditionPeriod?.Period.Start > duration
                select conditionPeriod;

            var alerts = (
                from conditionPeriod in inEffectOutOfRangePeriods
                select CreateAlertAsync(definition, miner, parameters, snapshotsList, token)).ToArray();

            if (alerts.Any())
            {
                return(ScanResult.Fail(await Task.WhenAll(alerts)));
            }

            return(ScanResult.Success);
        }
Пример #14
0
 private void StopMiner(Miner miner)
 {
     if (miner.IsRunning) {
         miner.Stop(MinerStopType.SWITCH);
         // wait 0.5 seconds before going on
         System.Threading.Thread.Sleep(ConfigManager.Instance.GeneralConfig.MinerRestartDelayMS);
     }
 }
Пример #15
0
            private void SwitchMinerAlgorithm(ref Miner m, Algorithm algorithm, string miningLocation, string worker)
            {
                // if is running and the current algorithm is the same skip
                if (m.IsRunning && m.CurrentAlgorithmType == algorithm.NiceHashID) {
                    return;
                }

                if (m.CurrentAlgorithmType != AlgorithmType.NONE && m.CurrentAlgorithmType != AlgorithmType.INVALID) {
                    m.Stop(MinerStopType.SWITCH);
                    // wait 0.5 seconds before going on
                    System.Threading.Thread.Sleep(ConfigManager.Instance.GeneralConfig.MinerRestartDelayMS);
                }

                var MaxProfitKey = algorithm.NiceHashID;

                // Wait before new start
                System.Threading.Thread.Sleep(ConfigManager.Instance.GeneralConfig.MinerRestartDelayMS);

                m.Start(algorithm,
                    "stratum+tcp://"
                    + Globals.NiceHashData[MaxProfitKey].name
                    + "." + miningLocation
                    + ".nicehash.com:"
                    + Globals.NiceHashData[MaxProfitKey].port, worker);
            }
Пример #16
0
        public void Checker(Uri uri, string toCheck)
        {
            Tape = true;

            this.StateChanged += CheckerPopup_StateChanged;

            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                ShowOrNot();

                Application.Current.MainWindow.IsVisibleChanged += MainWindow_IsVisibleChanged;
                Application.Current.MainWindow.StateChanged     += MainWindow_StateChanged;
                Application.Current.MainWindow.Activated        += MainWindow_Activated;
            });

            Application.Current.Dispatcher.Invoke(new Action(() => MainWindow.DispararEvento()));

            ProgressBar_Value           = 0;
            ProgressBar_IsIndeterminate = true;
            FileName    = "Initializing";
            StatusTitle = "Checking Instalation";
            Thread.Sleep(10);

            CheckInternet();

            StatusTitle = "Checking Instalation";

            bool trying = true;

            while (trying)
            {
                try
                {
                    FileName = "Removing old files";
                    string[] arquivosOdl = Directory.GetFiles(Environment.CurrentDirectory, "*.old", SearchOption.AllDirectories);
                    foreach (var arq in arquivosOdl)
                    {
                        if (!Tools.IsFileLocked(new FileInfo(arq)))
                        {
                            File.Delete(arq);
                        }
                    }
                    string[] arquivosDl = Directory.GetFiles(Environment.CurrentDirectory, "*.dl", SearchOption.AllDirectories);
                    foreach (var arq in arquivosDl)
                    {
                        if (!Tools.IsFileLocked(new FileInfo(arq)))
                        {
                            File.Delete(arq);
                        }
                    }

                    FileName = "Updating software parameters";
                    SoftwareParameters.Update(uri);

                    if (!(File.Exists(Environment.CurrentDirectory + @"\DoNotUpdate") || (Core.NextStart.Actions.loadedNextStartInstructions.useThisInstructions && Core.NextStart.Actions.loadedNextStartInstructions.ignoreUpdates)) && (toCheck == "all" || toCheck == "TrueMining"))
                    {
                        FileName = "Checking True Mining Version";
                        Thread.Sleep(20);

                        foreach (FileDetails file in SoftwareParameters.ServerConfig.TrueMiningFiles.files)
                        {
                            FileName = "Checking Files";
                            Thread.Sleep(20);

                            file.path = Tools.FormatPath(file.path);

                            if (!File.Exists(file.path + file.fileName) || Tools.FileSHA256(file.path + file.fileName) != file.sha256)
                            {
                                Downloader(file.dlLink, file.path, file.fileName, file.sha256);
                                needRestart = true;
                            }
                        }

                        if (needRestart)
                        {
                            HostFilesAd_Visibility = Visibility.Collapsed;
                            ProgressBar_Value      = 0;
                            FileName    = "Restarting";
                            StatusTitle = "Complete update, restart required";
                            User.Settings.SettingsSaver(true);
                            Thread.Sleep(3000);
                            Tape = false;

                            Application.Current.Dispatcher.Invoke((Action) delegate
                            {
                                System.Diagnostics.Process TrueMiningAsAdmin = new System.Diagnostics.Process();
                                TrueMiningAsAdmin.StartInfo = new System.Diagnostics.ProcessStartInfo()
                                {
                                    FileName        = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName,
                                    UseShellExecute = false,
                                };
                                if (Tools.HaveADM)
                                {
                                    TrueMiningAsAdmin.StartInfo.Verb = "runas";
                                }

                                try { TrueMiningAsAdmin.Start(); Miner.StopMiner(); } catch (Exception e) { MessageBox.Show(e.Message); }

                                Application.Current.Shutdown();
                            });
                        }
                    }

                    if (toCheck == "all" || toCheck == "ThirdPartyBinaries")
                    {
                        foreach (FileDetails file in SoftwareParameters.ServerConfig.ThirdPartyBinaries.files)
                        {
                            FileName = "Checking Files";
                            Thread.Sleep(20);

                            file.path = Tools.FormatPath(file.path);
                            if (!File.Exists(file.path + file.fileName) || Tools.FileSHA256(file.path + file.fileName) != file.sha256)
                            {
                                Downloader(file.dlLink, file.path, file.fileName, file.sha256);
                            }
                        }
                    }
                    HostFilesAd_Visibility = Visibility.Collapsed;
                    trying = false;
                }
                catch { }
            }

            FileName = "Complete";
            Thread.Sleep(100);

            Dispatcher.BeginInvoke((Action)(() => { this.Close(); }));
        }
Пример #17
0
        // Verifies a mining solution based on the block's difficulty
        // It does not submit it to the network.
        private JsonResponse onVerifyMiningSolution(Dictionary <string, object> parameters)
        {
            // Check that all the required query parameters are sent
            if (!parameters.ContainsKey("nonce"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'nonce' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }

            if (!parameters.ContainsKey("blocknum"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'blocknum' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }

            if (!parameters.ContainsKey("diff"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'diff' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }

            string nonce = (string)parameters["nonce"];

            if (nonce.Length < 1 || nonce.Length > 128)
            {
                Logging.info("Received incorrect verify nonce from miner.");
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INVALID_PARAMS, message = "Invalid nonce was specified"
                    }
                });
            }

            ulong blocknum = ulong.Parse((string)parameters["blocknum"]);
            Block block    = Node.blockChain.getBlock(blocknum, false, false);

            if (block == null)
            {
                Logging.info("Received incorrect verify block number from miner.");
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INVALID_PARAMS, message = "Invalid block number specified"
                    }
                });
            }

            ulong blockdiff = ulong.Parse((string)parameters["diff"]);

            byte[] solver_address = Node.walletStorage.getPrimaryAddress();

            bool verify_result = false;

            if (block.version <= BlockVer.v4)
            {
                verify_result = Miner.verifyNonce_v2(nonce, blocknum, solver_address, blockdiff);
            }
            else // >= 5
            {
                verify_result = Miner.verifyNonce_v3(nonce, blocknum, solver_address, blockdiff);
            }

            if (verify_result)
            {
                Logging.info("Received verify share: {0} #{1} - PASSED with diff {2}", nonce, blocknum, blockdiff);
            }
            else
            {
                Logging.info("Received verify share: {0} #{1} - REJECTED with diff {2}", nonce, blocknum, blockdiff);
            }

            return(new JsonResponse {
                result = verify_result, error = null
            });
        }
Пример #18
0
        // Returns an empty PoW block based on the search algorithm provided as a parameter
        private JsonResponse onGetMiningBlock(Dictionary <string, object> parameters)
        {
            if (!parameters.ContainsKey("algo"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'algo' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }

            int             algo       = int.Parse((string)parameters["algo"]);
            BlockSearchMode searchMode = BlockSearchMode.randomLowestDifficulty;

            if (algo == (int)BlockSearchMode.lowestDifficulty)
            {
                searchMode = BlockSearchMode.lowestDifficulty;
            }
            else if (algo == (int)BlockSearchMode.randomLowestDifficulty)
            {
                searchMode = BlockSearchMode.randomLowestDifficulty;
            }
            else if (algo == (int)BlockSearchMode.latestBlock)
            {
                searchMode = BlockSearchMode.latestBlock;
            }
            else if (algo == (int)BlockSearchMode.random)
            {
                searchMode = BlockSearchMode.random;
            }
            else
            {
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INVALID_PARAMS, message = "Invalid algorithm was specified"
                    }
                });
            }

            Block block = Miner.getMiningBlock(searchMode);

            if (block == null)
            {
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INTERNAL_ERROR, message = "Cannot retrieve mining block"
                    }
                });
            }

            byte[] solver_address = Node.walletStorage.getPrimaryAddress();

            Dictionary <string, Object> resultArray = new Dictionary <string, Object>
            {
                { "num", block.blockNum },      // Block number
                { "ver", block.version },       // Block version
                { "dif", block.difficulty },    // Block difficulty
                { "chk", block.blockChecksum }, // Block checksum
                { "adr", solver_address } // Solver address
            };

            return(new JsonResponse {
                result = resultArray, error = null
            });
        }
Пример #19
0
        // Verifies and submits a mining solution to the network
        private JsonResponse onSubmitMiningSolution(Dictionary <string, object> parameters)
        {
            // Check that all the required query parameters are sent
            if (!parameters.ContainsKey("nonce"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'nonce' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }

            if (!parameters.ContainsKey("blocknum"))
            {
                JsonError error = new JsonError {
                    code = (int)RPCErrorCode.RPC_INVALID_PARAMETER, message = "Parameter 'blocknum' is missing"
                };
                return(new JsonResponse {
                    result = null, error = error
                });
            }


            string nonce = (string)parameters["nonce"];

            if (nonce.Length < 1 || nonce.Length > 128)
            {
                Logging.info("Received incorrect nonce from miner.");
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INVALID_PARAMS, message = "Invalid nonce was specified"
                    }
                });
            }

            ulong blocknum = ulong.Parse((string)parameters["blocknum"]);
            Block block    = Node.blockChain.getBlock(blocknum, false, false);

            if (block == null)
            {
                Logging.info("Received incorrect block number from miner.");
                return(new JsonResponse {
                    result = null, error = new JsonError()
                    {
                        code = (int)RPCErrorCode.RPC_INVALID_PARAMS, message = "Invalid block number specified"
                    }
                });
            }

            Logging.info("Received miner share: {0} #{1}", nonce, blocknum);

            byte[] solver_address = Node.walletStorage.getPrimaryAddress();
            bool   verify_result  = false;

            if (block.version <= BlockVer.v4)
            {
                verify_result = Miner.verifyNonce_v2(nonce, blocknum, solver_address, block.difficulty);
            }
            else // >= 5
            {
                verify_result = Miner.verifyNonce_v3(nonce, blocknum, solver_address, block.difficulty);
            }
            bool send_result = false;

            // Solution is valid, try to submit it to network
            if (verify_result == true)
            {
                if (Miner.sendSolution(Crypto.stringToHash(nonce), blocknum))
                {
                    Logging.info("Miner share {0} ACCEPTED.", nonce);
                    send_result = true;
                }
            }
            else
            {
                Logging.warn("Miner share {0} REJECTED.", nonce);
            }

            return(new JsonResponse {
                result = send_result, error = null
            });
        }
Пример #20
0
 public MoveToAsteroid(Blackboard bb, Miner mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
 }
Пример #21
0
 static void Main(string[] args)
 {
     var txPool     = TransactionPool.Instance;
     var blockChain = new BlockChain(txPool);
     var miner      = new Miner(blockChain.Chain, txPool);
 }
Пример #22
0
 public CollectResources(Blackboard bb, Miner mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
     lastmine = Time.time;
 }
Пример #23
0
 public Drinking(Miner _miner)
 {
     miner     = _miner;
     minerData = miner.minerData;
 }
Пример #24
0
 public ReturnToBase(Blackboard bb, Miner mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
 }
Пример #25
0
        public async Task StartMiner()
        {
            Dispatcher.Invoke(() =>
            {
                isMining           = true;
                buttonMine.Content = "Stop mining";
                Write("Miner started");
            });

            try
            {
                var mineableBlock = await Miner.GetMineableBlock(httpProvider);

                if (mineableBlock != null)
                {
                    Dispatcher.Invoke(() => { miner = new Miner(mineableBlock); });

                    while (isMining)
                    {
                        var minedBlock = await miner.MineRound(ActiveWallet);

                        if (minedBlock != null) //relay new block
                        {
                            Dispatcher.Invoke(() =>
                            {
                                Write($"Miner has found new block! Block height: {minedBlock.Height}, Hashrate: {miner.GetHashrate()}");
                                httpProvider.PeerPost <string, string>(HexConverter.ToPrefixString(minedBlock.Serialize()), @"http://127.0.0.1:8125/block/relay").Wait();
                            });

                            mineableBlock = await Miner.GetMineableBlock(new HttpProvider());

                            if (mineableBlock != null)
                            {
                                Dispatcher.Invoke(() => { miner = new Miner(mineableBlock); });
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            var newMineableBlock = await Miner.GetMineableBlock(httpProvider);

                            if (newMineableBlock.Height != mineableBlock.Height)
                            {
                                mineableBlock = newMineableBlock;
                            }
                        }
                    }
                }
                else
                {
                    Dispatcher.Invoke(() => { Write("Miner could not get work from node. Check connection"); });
                }
            }
            catch (Exception e)
            {
                Dispatcher.Invoke(() => { Write($"Miner has encountered an exception\nStack trace: {e.StackTrace}\nMessage: {e.Message}"); });
            }

            Dispatcher.Invoke(() =>
            {
                StopMiner();
                Write("Miner stopped");
            });
        }
Пример #26
0
 public MinerCalculateFleeLocation(Blackboard bb, Miner mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
 }
Пример #27
0
 public MinerInfo GetMinerInfo(Miner miner)
 => ActiveMiners.TryGetValue(miner.Id, out var minerStatus)
         ? new MinerInfo(miner.Id, true, minerStatus.Status.PlotCount, miner.Name, miner.Earnings, miner.OwnerId)
         : new MinerInfo(miner.Id, false, -1, miner.Name, miner.Earnings, miner.OwnerId);
Пример #28
0
 public MinerMoveTo(Blackboard bb, Miner mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
 }
Пример #29
0
        private void NextBenchmark()
        {
            ++_benchmarkCurrentIndex;
            if (_benchmarkCurrentIndex > 0)
            {
                _benchmarkForm.StepUpBenchmarkStepProgress();
            }
            if (_benchmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            if (_benchmarkAlgorithmQueue.Count > 0)
            {
                _currentAlgorithm = _benchmarkAlgorithmQueue.Dequeue();
            }

            if (Device != null && _currentAlgorithm != null)
            {
                _currentMiner = MinerFactory.CreateMiner(Device, _currentAlgorithm);

                /*
                 * if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStak && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight
                 *  && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters)
                 *  && _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false) {
                 *  _cpuBenchmarkStatus = new CPUBenchmarkStatus(Globals.ThreadsPerCPU);
                 *  _currentAlgorithm.LessThreads = _cpuBenchmarkStatus.LessTreads;
                 * } else {
                 *  _cpuBenchmarkStatus = null;
                 * }
                 */
                _cpuBenchmarkStatus = null;

                if (_currentAlgorithm.MinerBaseType == MinerBaseType.Claymore &&
                    _currentAlgorithm.NiceHashID == AlgorithmType.Equihash &&
                    _currentAlgorithm.ExtraLaunchParameters != null &&
                    !_currentAlgorithm.ExtraLaunchParameters.Contains("-asm"))
                {
                    _claymoreZcashStatus = new ClaymoreZcashBenchHelper(_currentAlgorithm.ExtraLaunchParameters);
                    _currentAlgorithm.ExtraLaunchParameters = _claymoreZcashStatus.GetTestExtraParams();
                }
                else
                {
                    _claymoreZcashStatus = null;
                }

                if (_currentAlgorithm is DualAlgorithm dualAlgo && dualAlgo.TuningEnabled)
                {
                    dualAlgo.StartTuning();
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null && Device != null)
            {
                _currentMiner.InitBenchmarkSetup(new MiningPair(Device, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(_performanceType, Device.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (_cpuBenchmarkStatus != null)
                {
                    _cpuBenchmarkStatus.Time = time;
                }
                if (_claymoreZcashStatus != null)
                {
                    _claymoreZcashStatus.Time = time;
                }

                // dagger about 4 minutes
                //var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                _benchmarkForm.AddToStatusCheck(Device, _currentAlgorithm);

                _currentMiner.BenchmarkStart(time, this);
            }
            else
            {
                NextBenchmark();
            }
        }
Пример #30
0
        private string GetCommandLineString(Miner miner)
        {
            string commandLine = string.Empty;

            if (miner == Miner.GPU)
            {
                string CpuAssist = string.Empty;
                if (cbxCpuAssist_CudaMiner.SelectedIndex == 0) //None - offload everything to GPU
                    CpuAssist = "2";
                else if (cbxCpuAssist_CudaMiner.SelectedIndex == 1) //Multi-thread
                    CpuAssist = "1";
                else if (cbxCpuAssist_CudaMiner.SelectedIndex == 2) //Single-thread
                    CpuAssist = "0";

                commandLine =
                    "-o " + txtPoolAddress_CudaMiner.Text + //Pool address
                    " -O " + txtWorkerName_CudaMiner.Text + ":" + txtWorkerPassword_CudaMiner.Text + //Username/Password
                    " -d " + cbxDevice_CudaMiner.SelectedIndex.ToString() + //Device (Video card)
                    " -a " + cbxAlgorithm_CudaMiner.Text + //Algorithm
                    " -l " + cbxKernel_CudaMiner.Text + //Kernel
                    " -H " + CpuAssist + //Hash parallel (CPU Assist)
                    " -C " + cbxTextureCache_CudaMiner.SelectedIndex.ToString() + //Texture cache
                    " -L " + txtLookupGap_CudaMiner.Text + //Lookup Gap
                    " -b " + txtBatchsize_CudaMiner.Text + //Batchsize
                    " -i " + (chkInteractive_CudaMiner.Checked ? "1" : "0") + //Interactive
                    " -m " + (chkSingleMemory_CudaMiner.Checked ? "1" : "0") + //Single Memory
                    (chkDebug_CudaMiner.Checked ? " -D" : ""); //Debug flag
            }
            else if (miner == Miner.CPU)
            {
                commandLine =
                    "-o " + txtPoolAddress_CpuMiner.Text +
                    " -u " + txtWorkerName_CpuMiner.Text +
                    " -p " + txtWorkerPassword_CpuMiner.Text +
                    (chkDebug_CpuMiner.Checked ? " -D" : "") +
                    (!chkLongPoll_CpuMiner.Checked ? " --no-longpoll" : "") +
                    (!chkNoStratum_CpuMiner.Checked ? " --no-stratum" : "");
            }

            return commandLine;
        }
Пример #31
0
        void NextBenchmark()
        {
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            Tuple <ComputeDevice, Queue <Algorithm> > currentDeviceAlgosTuple;
            Queue <Algorithm> algorithmBenchmarkQueue;

            while (_benchmarkDevicesAlgorithmQueue.Count > 0)
            {
                currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice          = currentDeviceAlgosTuple.Item1;
                algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if (algorithmBenchmarkQueue.Count != 0)
                {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                }
                else
                {
                    _benchmarkDevicesAlgorithmQueue.RemoveAt(0);
                }
            }

            if (_currentDevice != null && _currentAlgorithm != null)
            {
                _currentMiner = MinerFactory.CreateMiner(_currentDevice, _currentAlgorithm);
                if (_currentAlgorithm.MinerBaseType == MinerBaseType.XmrStackCPU && _currentAlgorithm.NiceHashID == AlgorithmType.CryptoNight && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters) && _currentAlgorithm.ExtraLaunchParameters.Contains("enable_ht=true") == false)
                {
                    __CPUBenchmarkStatus          = new CPUBenchmarkStatus(Globals.ThreadsPerCPU);
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                }
                else
                {
                    __CPUBenchmarkStatus = null;
                }
                if (_currentAlgorithm.MinerBaseType == MinerBaseType.ClaymoreAMD && _currentAlgorithm.NiceHashID == AlgorithmType.Equihash && _currentAlgorithm.ExtraLaunchParameters != null && !_currentAlgorithm.ExtraLaunchParameters.Contains("-asm"))
                {
                    __ClaymoreZcashStatus = new ClaymoreZcashStatus(_currentAlgorithm.ExtraLaunchParameters);
                    _currentAlgorithm.ExtraLaunchParameters = __ClaymoreZcashStatus.GetTestExtraParams();
                }
                else
                {
                    __ClaymoreZcashStatus = null;
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null)
            {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(BenchmarkPerformanceType.Quick, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (__CPUBenchmarkStatus != null)
                {
                    __CPUBenchmarkStatus.Time = time;
                }
                if (__ClaymoreZcashStatus != null)
                {
                    __ClaymoreZcashStatus.Time = time;
                }

                // dagger about 4 minutes
                var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                // dotCount = 0;
                //_benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(time, this);
            }
            else
            {
                NextBenchmark();
            }
        }
Пример #32
0
        private void ResetAddMinerFields(Miner miner)
        {
            if (miner == Miner.GPU)
            {
                txtName_CudaMiner.Text = "Name";
                txtPoolAddress_CudaMiner.Text = "stratum+tcp://pool.of.choice:0000";
                txtWorkerName_CudaMiner.Text = "Worker Name";
                txtWorkerPassword_CudaMiner.Text = "Worker Password";

                txtName_CudaMiner.ForeColor = Color.DarkGray;
                txtPoolAddress_CudaMiner.ForeColor = Color.DarkGray;
                txtWorkerName_CudaMiner.ForeColor = Color.DarkGray;
                txtWorkerPassword_CudaMiner.ForeColor = Color.DarkGray;

                cbxAlgorithm_CudaMiner.SelectedIndex = 0;
                cbxKernel_CudaMiner.SelectedIndex = 0;
                cbxCpuAssist_CudaMiner.SelectedIndex = 0;
                cbxTextureCache_CudaMiner.SelectedIndex = 0;
                cbxDevice_CudaMiner.SelectedIndex = 0;

                txtLookupGap_CudaMiner.Text = "1";
                txtBatchsize_CudaMiner.Text = "1024";

                chkDebug_CudaMiner.Checked = false;
                chkInteractive_CudaMiner.Checked = false;
                chkSingleMemory_CudaMiner.Checked = false;
            }
            else if (miner == Miner.CPU)
            {
                txtName_CpuMiner.Text = "Name";
                txtPoolAddress_CpuMiner.Text = "stratum+tcp://pool.of.choice:0000";
                txtWorkerName_CpuMiner.Text = "Worker Name";
                txtWorkerPassword_CpuMiner.Text = "Worker Password";

                txtName_CpuMiner.ForeColor = Color.DarkGray;
                txtPoolAddress_CpuMiner.ForeColor = Color.DarkGray;
                txtWorkerName_CpuMiner.ForeColor = Color.DarkGray;
                txtWorkerPassword_CpuMiner.ForeColor = Color.DarkGray;

                chkDebug_CpuMiner.Checked = false;
            }
        }
Пример #33
0
 public abstract bool EndAlert(AlertDefinition definition, Miner miner, Alert alert, IEnumerable <Snapshot> snapshots, DateTime scanTime);
Пример #34
0
 public abstract Task <ScanResult> PerformScanAsync(IEnumerable <Alert> activeAlerts, AlertDefinition definition, Miner miner, IEnumerable <Snapshot> snapshots, DateTime scanTime, CancellationToken token);
Пример #35
0
 public MinerFleeDecorator(BTNode WrappedNode, Blackboard bb, Miner mine) : base(WrappedNode, bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = mine;
 }
Пример #36
0
        void NextBenchmark()
        {
            if (_bechmarkCurrentIndex > -1)
            {
                StepUpBenchmarkStepProgress();
            }
            ++_bechmarkCurrentIndex;
            if (_bechmarkCurrentIndex >= _benchmarkAlgorithmsCount)
            {
                EndBenchmark();
                return;
            }

            Tuple <ComputeDevice, Queue <Algorithm> > currentDeviceAlgosTuple;
            Queue <Algorithm> algorithmBenchmarkQueue;

            while (_benchmarkDevicesAlgorithmQueue.Count > 0)
            {
                currentDeviceAlgosTuple = _benchmarkDevicesAlgorithmQueue[0];
                _currentDevice          = currentDeviceAlgosTuple.Item1;
                algorithmBenchmarkQueue = currentDeviceAlgosTuple.Item2;
                if (algorithmBenchmarkQueue.Count != 0)
                {
                    _currentAlgorithm = algorithmBenchmarkQueue.Dequeue();
                    break;
                }
                else
                {
                    _benchmarkDevicesAlgorithmQueue.RemoveAt(0);
                }
            }

            if (_currentDevice != null && _currentAlgorithm != null)
            {
                _currentMiner = MinerFactory.CreateMiner(_currentDevice, _currentAlgorithm);
                if (_currentDevice.DeviceType == DeviceType.CPU && string.IsNullOrEmpty(_currentAlgorithm.ExtraLaunchParameters))
                {
                    __CPUBenchmarkStatus          = new CPUBenchmarkStatus();
                    _currentAlgorithm.LessThreads = __CPUBenchmarkStatus.LessTreads;
                }
                else
                {
                    __CPUBenchmarkStatus = null;
                }
            }

            if (_currentMiner != null && _currentAlgorithm != null)
            {
                _benchmarkMiners.Add(_currentMiner);
                CurrentAlgoName = AlgorithmNiceHashNames.GetName(_currentAlgorithm.NiceHashID);
                _currentMiner.InitBenchmarkSetup(new MiningPair(_currentDevice, _currentAlgorithm));

                var time = ConfigManager.GeneralConfig.BenchmarkTimeLimits
                           .GetBenchamrktime(benchmarkOptions1.PerformanceType, _currentDevice.DeviceGroupType);
                //currentConfig.TimeLimit = time;
                if (__CPUBenchmarkStatus != null)
                {
                    __CPUBenchmarkStatus.Time = time;
                }

                // dagger about 4 minutes
                var showWaitTime = _currentAlgorithm.NiceHashID == AlgorithmType.DaggerHashimoto ? 4 * 60 : time;

                dotCount = 0;
                _benchmarkingTimer.Start();

                _currentMiner.BenchmarkStart(time, this);
                algorithmsListView1.SetSpeedStatus(_currentDevice, _currentAlgorithm,
                                                   getDotsWaitString());
            }
            else
            {
                NextBenchmark();
            }
        }
Пример #37
0
        public frmMiner(Type type, Miner miner = Miner.GPU, Guid guid = default(Guid))
        {
            InitializeComponent();
            string strError = string.Empty;

            SetTips();

            devices = new DevicesCall();
            settingsCall = new SettingCall();

            settings = settingsCall.GetSettings(ref strError);
            this.Icon = settingsCall.GetApplicationIcon();

            AddVideoCardsToComboBox();
            ResetAddMinerFields(Miner.GPU);
            ResetAddMinerFields(Miner.CPU);
            cbxMiner.SelectedIndex = 0; //Default to GPU
            minerType = type;
            minerGuid = guid;

            if (type == Type.Add)
            {
                this.Text = "Add Miner";
                btnAddEditCpuMiner.Text = "Add";
            }
            else if (type == Type.Edit)
            {
                if (guid == default(Guid))
                    MessageBox.Show("The user should never see this message.\r\n\r\nEdit was selected, but no GUID was passed.", "Err...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                {
                    if (Debugger.IsAttached)
                        lblOldGuid.Visible = true;

                    txtName_CudaMiner.ForeColor = Color.Black;
                    txtPoolAddress_CudaMiner.ForeColor = Color.Black;
                    txtWorkerName_CudaMiner.ForeColor = Color.Black;
                    txtWorkerPassword_CudaMiner.ForeColor = Color.Black;

                    txtName_CpuMiner.ForeColor = Color.Black;
                    txtPoolAddress_CpuMiner.ForeColor = Color.Black;
                    txtWorkerName_CpuMiner.ForeColor = Color.Black;
                    txtWorkerPassword_CpuMiner.ForeColor = Color.Black;

                    if (miner == Miner.GPU)
                    {
                        tcMiners.SelectedIndex = 0;
                        cbxMiner.SelectedIndex = 0;
                        btnAddEditCudaMiner.Text = "Edit Miner";

                        GpuMinerData selectedMiner = settings.GpuMiners.SingleOrDefault(x => x.MinerGUID == guid);
                        txtName_CudaMiner.Text = selectedMiner.Name;
                        txtPoolAddress_CudaMiner.Text = selectedMiner.PoolAddress;
                        txtWorkerName_CudaMiner.Text = selectedMiner.WorkerName;
                        txtWorkerPassword_CudaMiner.Text = selectedMiner.WorkerPassword;
                        cbxDevice_CudaMiner.SelectedIndex = selectedMiner.Device;
                        cbxAlgorithm_CudaMiner.Text = selectedMiner.Algorithm;
                        cbxCpuAssist_CudaMiner.Text = selectedMiner.CpuAssist;
                        cbxTextureCache_CudaMiner.Text = selectedMiner.TextureCache;
                        txtLookupGap_CudaMiner.Text = selectedMiner.LookupGap.ToString();
                        txtBatchsize_CudaMiner.Text = selectedMiner.Batchsize.ToString();
                        chkInteractive_CudaMiner.Checked = selectedMiner.Interactive;
                        chkSingleMemory_CudaMiner.Checked = selectedMiner.SingleMemory;
                        chkDebug_CudaMiner.Checked = selectedMiner.Debug;
                    }
                    else if (miner == Miner.CPU)
                    {
                        tcMiners.SelectedIndex = 1;
                        cbxMiner.SelectedIndex = 1;
                        btnAddEditCpuMiner.Text = "Edit Miner";

                        CpuMinerData selectedMiner = settings.CpuMiners.SingleOrDefault(x => x.MinerGUID == guid);
                        txtName_CpuMiner.Text = selectedMiner.Name;
                        txtPoolAddress_CpuMiner.Text = selectedMiner.PoolAddress;
                        txtWorkerName_CpuMiner.Text = selectedMiner.WorkerName;
                        txtWorkerPassword_CpuMiner.Text = selectedMiner.WorkerPassword;
                    }

                    cbxMiner.Enabled = false;

                    this.Text = "Edit Miner";
                    btnAddEditCpuMiner.Text = "Edit";

                    lblOldGuid.Text = guid.ToString().ToUpper();
                }
            }
        }
Пример #38
0
 public MinerWaitTillAtLocation(Blackboard bb, Miner Mine) : base(bb)
 {
     mBB      = (MinerBB)bb;
     MinerRef = Mine;
 }
Пример #39
0
 public Sleeping(Miner _miner)
 {
     miner     = _miner;
     minerData = miner.minerData;
 }
Пример #40
0
 public MakingBankDeposit(Miner _miner)
 {
     miner     = _miner;
     minerData = miner.minerData;
 }
Пример #41
0
        private bool DoesMinerExist(Miner miner, string guid)
        {
            bool exist = false;

            if (miner == Miner.GPU)
            {
                foreach (DataGridViewRow row in dgvMiners.Rows)
                    if (row.Cells[0].Value.ToString() == guid)
                        exist = true;
            }

            return exist;
        }
    void Start()
    {
        textureMap = new Texture2D(width, height);
        textureMap.filterMode = FilterMode.Point;

        map = new MapCell [width,height];

        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                map[i,j] = new MapCell();
                UpdateVisualMap(i, j, Color.gray);
            }
        }
        miners = new List<Miner>();
        for (int i = 0; i < 4; i++) {
            Miner miner = new Miner(width / 2, height / 2, map);
            miners.Add (miner);
        }
        DigMap();

        ShowMap ();
        //showDoors ();
        ToolChain ();
    }