public MiningParameters GetMiningParameters()
        {
            Program.Print("[INFO] Checking latest parameters from network...");

            m_cacheParameters = MiningParameters.GetSoloMiningParameters(m_contract, m_minerAddress);

            return(m_cacheParameters);
        }
Example #2
0
        public MiningParameters GetMiningParameters()
        {
            Program.Print("[INFO] Checking latest parameters from network...");
            bool success   = true;
            var  startTime = DateTime.Now;

            try
            {
                return(MiningParameters.GetSoloMiningParameters(MinerAddress, m_getMiningDifficulty, m_getMiningTarget, m_getChallengeNumber));
            }
            catch (Exception ex)
            {
                success = false;
                throw ex;
            }
            finally
            {
                if (success)
                {
                    var tempLatency = (int)(DateTime.Now - startTime).TotalMilliseconds;
                    try
                    {
                        using (var ping = new Ping())
                        {
                            var submitUrl = SubmitURL.Contains("://") ? SubmitURL.Split("://")[1] : SubmitURL;
                            try
                            {
                                var response = ping.Send(submitUrl);
                                if (response.RoundtripTime > 0)
                                {
                                    tempLatency = (int)response.RoundtripTime;
                                }
                            }
                            catch
                            {
                                try
                                {
                                    submitUrl = submitUrl.Split('/').First();
                                    var response = ping.Send(submitUrl);
                                    if (response.RoundtripTime > 0)
                                    {
                                        tempLatency = (int)response.RoundtripTime;
                                    }
                                }
                                catch
                                {
                                    try
                                    {
                                        submitUrl = submitUrl.Split(':').First();
                                        var response = ping.Send(submitUrl);
                                        if (response.RoundtripTime > 0)
                                        {
                                            tempLatency = (int)response.RoundtripTime;
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                    catch { }
                    Latency = tempLatency;
                }
            }
        }