コード例 #1
0
        private MiningParameters GetMiningParameters()
        {
            Program.Print(string.Format("[INFO] Checking latest parameters from master URL: {0}", SubmitURL));

            var getChallenge  = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetChallenge);
            var getDifficulty = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetDifficulty);
            var getTarget     = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetTarget);
            var getPause      = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetPause);

            var success   = true;
            var startTime = DateTime.Now;

            try
            {
                return(MiningParameters.GetMiningParameters(SubmitURL,
                                                            getChallenge: getChallenge,
                                                            getDifficulty: getDifficulty,
                                                            getTarget: getTarget,
                                                            getPause: getPause));
            }
            catch (Exception ex)
            {
                HandleException(ex);
                success = false;
            }
            finally
            {
                if (success)
                {
                    Latency = (int)(DateTime.Now - startTime).TotalMilliseconds;
                }
            }
            return(null);
        }
コード例 #2
0
        public SlaveInterface(string masterURL, int updateInterval, int hashratePrintInterval)
            : base(updateInterval, hashratePrintInterval)
        {
            m_isGetMiningParameters = false;
            SubmitURL = masterURL;

            Program.Print(string.Format("[INFO] Waiting for master instance ({0}) to start...", SubmitURL));

            var getMasterAddress = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetMinerAddress);
            var getMaximumTarget = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetMaximumTarget);
            var getKingAddress   = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetKingAddress);
            var getPoolMining    = Miner.MasterInterface.GetMasterParameter(Miner.MasterInterface.RequestMethods.GetPoolMining);

            var retryCount = 0;

            while (true)
            {
                try
                {
                    var parameters = MiningParameters.GetMiningParameters(SubmitURL,
                                                                          getEthAddress: getMasterAddress,
                                                                          getMaximumTarget: getMaximumTarget,
                                                                          getKingAddress: getKingAddress,
                                                                          getPoolMining: getPoolMining);
                    m_isPool               = parameters.IsPoolMining;
                    MinerAddress           = parameters.EthAddress;
                    MaxTarget              = parameters.MaximumTarget;
                    Miner.Work.KingAddress = parameters.KingAddressByte20;
                    break;
                }
                catch (Exception ex)
                {
                    retryCount++;
                    if (retryCount > 3)
                    {
                        HandleException(ex);
                    }

                    Task.Delay(1000).Wait();
                }
            }

            if (hashratePrintInterval > 0)
            {
                m_hashPrintTimer          = new Timer(hashratePrintInterval);
                m_hashPrintTimer.Elapsed += HashPrintTimer_Elapsed;
                m_hashPrintTimer.Start();
            }
        }