Пример #1
0
        public void ClearOutTimeDB()
        {
            using (DbSnapshot snapshot = PoolDBStore.GetSnapshot(0, true))
            {
                string str_Counted = snapshot.Get("Pool_Counted");
                long   counted     = 0;
                long.TryParse(str_Counted, out counted);
                string        str_MR          = snapshot.Get($"Pool_MR_{counted-1}");
                MinerRewardDB minerRewardLast = null;
                if (!string.IsNullOrEmpty(str_MR))
                {
                    minerRewardLast = JsonHelper.FromJson <MinerRewardDB>(str_MR);
                }
                if (minerRewardLast != null)
                {
                    bool bCommit  = false;
                    int  delCount = 5760 * 3;
                    for (long ii = counted - 2; ii > counted - delCount; ii--)
                    {
                        string key = $"Pool_MR_{ii}";
                        if (!string.IsNullOrEmpty(snapshot.Get(key)))
                        {
                            bCommit = true;
                            snapshot.Delete(key);
                        }
                        else
                        {
                            break;
                        }
                    }

                    // Miner
                    for (long ii = minerRewardLast.minHeight; ii > minerRewardLast.minHeight - delCount; ii--)
                    {
                        string key = $"Pool_H2_{ii}";
                        if (!string.IsNullOrEmpty(snapshot.Get(key)))
                        {
                            bCommit = true;
                            snapshot.Delete(key);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (bCommit)
                    {
                        snapshot.Commit();
                    }
                }
            }
        }
Пример #2
0
        public void ClearOutTimeDB()
        {
            using (DbSnapshot snapshot = PoolDBStore.GetSnapshot())
            {
                // Miner
                string json         = snapshot.Get("Pool_H_Miner");
                long   height_miner = -1;
                if (!string.IsNullOrEmpty(json))
                {
                    long.TryParse(json, out height_miner);
                }

                for (long ii = OutTimeDBMiner; ii < OutTimeDBMiner * 3; ii++)
                {
                    string key = "Pool_H_" + (height_miner - ii);
                    if (!string.IsNullOrEmpty(snapshot.Get(key)))
                    {
                        snapshot.Delete("Pool_H_" + (height_miner - ii));
                    }
                    else
                    {
                        break;
                    }
                }

                long   counted     = 0;
                string str_Counted = snapshot.Get("Pool_Counted");
                long.TryParse(str_Counted, out counted);
                for (long ii = OutTimeDBCounted; ii < OutTimeDBCounted * 3; ii++)
                {
                    long index = counted - ii;
                    if (!string.IsNullOrEmpty(snapshot.Get($"Pool_MR_{index}")))
                    {
                        snapshot.Delete($"Pool_MR_{index}");
                        snapshot.Delete($"Pool_MT_{index}");
                    }
                    else
                    {
                        break;
                    }
                }
                snapshot.Commit();
            }
        }