示例#1
0
        private void UpdateRunningTime()
        {
            long totalTime = CurrentBenchmark.TimeUpdated - CurrentBenchmark.TimeStarted;

            CurrentBenchmark.AvailableTimeStamps = CurrentBenchmark.AvailableTimeStamps.OrderBy(ts => ts.TimeStamp).ToList();
            if (totalTime > 0)
            {
                for (int index = 0; index < CurrentBenchmark.AvailableTimeStamps.Count; index++)
                {
                    Benchmark.Availability availableTimeStamp = CurrentBenchmark.AvailableTimeStamps[index];
                    if (!availableTimeStamp.Available && index + 1 < CurrentBenchmark.AvailableTimeStamps.Count)
                    {
                        Benchmark.Availability nextAvailableTimeStamp = CurrentBenchmark.AvailableTimeStamps[index + 1];
                        if (nextAvailableTimeStamp.Available)
                        {
                            totalTime -= (uint)(nextAvailableTimeStamp.TimeStamp - availableTimeStamp.TimeStamp);
                        }
                    }
                }

                CurrentBenchmark.CurrentStatistic.TimeRunning = (uint)totalTime;
                if (totalTime > 0)
                {
                    CurrentBenchmark.CurrentStatistic.HashCountedRate =
                        CurrentBenchmark.CurrentStatistic.TotalHashCount / totalTime;

                    if (CurrentBenchmark.Algorithm == "quark" || CurrentBenchmark.Algorithm == "anime")
                    {
                        CurrentBenchmark.CurrentStatistic.HashCountedRate =
                            CurrentBenchmark.CurrentStatistic.HashCountedRate / 2;
                    }
                }
            }
        }
示例#2
0
        public void Update(Dictionary <string, string>[][] allApiResults, int[] pingTimes)
        {
            Dictionary <string, string>[] history = allApiResults[3];
            Dictionary <string, string>[] summary     = allApiResults[0];
            Dictionary <string, string>[] poolInfo    = allApiResults[1];
            Dictionary <string, string>[] totalHwInfo = allApiResults[2];
            Dictionary <string, string>   rightHwInfo = new Dictionary <string, string>();

            foreach (Dictionary <string, string> hwInfo in totalHwInfo)
            {
                if (Info.Bus == PruvotApi.GetDictValue <int>(hwInfo, "BUS"))
                {
                    rightHwInfo = hwInfo;
                    break;
                }
            }

            string    liveAlgo         = PruvotApi.GetDictValue <string>(summary[0], "ALGO");
            Benchmark currentBenchmark = GetCurrentBenchmark(liveAlgo);

            Benchmark.Setup liveSetup = GetLiveSetup(rightHwInfo, totalHwInfo[totalHwInfo.Length - 1], summary, poolInfo);

            // If currentBenchmark remained null because of an unknown algo,new install or change of setup,
            // It will create a new benchmark and update again
            if (currentBenchmark != null && liveSetup.Equals(currentBenchmark.MinerSetup))
            {
                Benchmark.Availability availability = currentBenchmark.AvailableTimeStamps.LastOrDefault();
                if (availability != null && availability.Available == false)
                {
                    ChangeAvailability(true, availability.RequestedByClose, CurrentBenchmark);
                }

                if (currentBenchmark != CurrentBenchmark)
                {
                    ChangeAvailability(false, false, CurrentBenchmark);
                    CurrentBenchmark = currentBenchmark;
                }

                UpdateSensors(rightHwInfo, pingTimes);

                UpdateHashLog(history);

                UpdateStats();
                // Calculates the statistics from previous information
            }
            else
            {
                CreateNewBenchMark(liveAlgo, liveSetup);
                Update(allApiResults, pingTimes);
            }
        }
示例#3
0
        private void UpdateHashLog(Dictionary <string, string>[] history)
        {
            if (history == null)
            {
                return;
            }

            foreach (Dictionary <string, string> hash in history)
            {
                Benchmark.HashEntry hashEntry = new Benchmark.HashEntry
                {
                    TimeStamp  = PruvotApi.GetDictValue <uint>(hash, "TS"),
                    HashRate   = PruvotApi.GetDictValue <decimal>(hash, "KHS"),
                    HashCount  = PruvotApi.GetDictValue <uint>(hash, "COUNT"),
                    Found      = PruvotApi.GetDictValue <uint>(hash, "FOUND"),
                    Height     = PruvotApi.GetDictValue <uint>(hash, "H"),
                    Difficulty = PruvotApi.GetDictValue <decimal>(hash, "DIFF")
                };

                if (CurrentBenchmark.HashLogs.Add(hashEntry))
                {
                    if (CurrentBenchmark.TimeStarted == 0L || hashEntry.TimeStamp < CurrentBenchmark.TimeStarted)
                    {
                        CurrentBenchmark.TimeStarted = hashEntry.TimeStamp;
                    }

                    if (CurrentBenchmark.TimeUpdated == 0L || hashEntry.TimeStamp > CurrentBenchmark.TimeUpdated)
                    {
                        CurrentBenchmark.TimeUpdated = hashEntry.TimeStamp;
                    }

                    Benchmark.Availability availabilityTimestamp = CurrentBenchmark.AvailableTimeStamps.LastOrDefault();
                    if (availabilityTimestamp != null && hashEntry.TimeStamp < availabilityTimestamp.TimeStamp &&
                        availabilityTimestamp.Available && availabilityTimestamp.RequestedByClose)
                    {
                        // If the last off/on of the availability occurred later than this histo item,
                        // the on switch should be placed earlier
                        Benchmark.Availability availability = new Benchmark.Availability
                        {
                            TimeStamp = hashEntry.TimeStamp,
                            //Stratum = CurrentBenchmark == null ? string.Empty : CurrentBenchmark.MinerSetup.MiningUrl,
                            Available        = true,
                            RequestedByClose = true
                        };
                        CurrentBenchmark.AvailableTimeStamps[CurrentBenchmark.AvailableTimeStamps.Count - 1] = availability;
                    }
                }
            }
        }
示例#4
0
        public void ChangeAvailability(bool available, bool monitorClosing = false, Benchmark benchmark = null)
        {
            if (benchmark == null)
            {
                if (BenchLogs == null || BenchLogs.Count == 0)
                {
                    return;
                }
                benchmark = CurrentBenchmark ?? BenchLogs.Last();
            }

            long unixTimeStamp = UnixTimeStamp();

            if (benchmark.AvailableTimeStamps.Count > 0)
            {
                Benchmark.Availability prevAvailableTimeStamp =
                    benchmark.AvailableTimeStamps[benchmark.AvailableTimeStamps.Count - 1];
                if (prevAvailableTimeStamp.TimeStamp != unixTimeStamp && prevAvailableTimeStamp.Available != available)
                {
                    if (available)
                    {
                        benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
                        {
                            TimeStamp        = unixTimeStamp,
                            Available        = true,
                            RequestedByClose = prevAvailableTimeStamp.RequestedByClose
                        });
                    }
                    else
                    {
                        benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
                        {
                            TimeStamp        = unixTimeStamp,
                            Available        = false,
                            RequestedByClose = monitorClosing
                        });
                    }
                }
            }
            else
            {
                benchmark.AvailableTimeStamps.Add(new Benchmark.Availability()
                {
                    TimeStamp        = unixTimeStamp,
                    Available        = true,
                    RequestedByClose = monitorClosing
                });
            }
        }