static public void test_ergodic2(long height, string filename) { // //DBTests tests = new DBTests(); //tests.SetUp(); //tests.Snapshot(); //var tempPath = System.IO.Directory.GetCurrentDirectory(); //var randName = "Data\\LevelDB1"; //var DatabasePath = System.IO.Path.Combine(tempPath, randName); //LevelDBStore dbstore = new LevelDBStore().Init(DatabasePath); LevelDBStore dbstore = Entity.Root.GetComponent <LevelDBStore>(); // Create new iterator lock (dbstore.db) { string sum = "0"; dbstore.UndoTransfers(height); using (var it = dbstore.db.CreateIterator()) { File.Delete("./" + filename + ".csv"); File.AppendAllText("./" + filename + ".csv", "height:" + height + "版本:" + NodeManager.networkIDCur + "\n"); // Iterate in reverse to print the values as strings for (it.SeekToFirst(); it.IsValid(); it.Next()) { //Log.Info($"Value as string: {it.KeyAsString()}"); if ((!it.KeyAsString().Contains("undo")) && (!it.KeyAsString().Contains("Undo"))) { if (it.KeyAsString().IndexOf("Accounts___") == 0) { try { Console.WriteLine($"Value as string: {it.ValueAsString()}"); Dictionary <string, Dictionary <string, object> > kv = JsonHelper.FromJson <Dictionary <string, Dictionary <string, object> > >(it.ValueAsString()); //all += long.Parse(kv["obj"]["amount"].ToString()); File.AppendAllText("./" + filename + ".csv", kv["obj"]["address"].ToString() + "," + kv["obj"]["amount"].ToString() + "\n"); BigHelper.Add(kv["obj"]["amount"].ToString(), sum); } catch (Exception e) { Console.WriteLine(it.KeyAsString()); Console.WriteLine($"出错了: {it.ValueAsString()}"); Console.WriteLine(e.Message); break; } } else if (it.KeyAsString().Contains("Storages")) { var kv = JsonHelper.FromJson <Dictionary <string, Dictionary <string, byte[]> > >(it.ValueAsString()); var json = SortJson(JToken.Parse(kv["obj"]["jsonData"].ToStr()), null); File.AppendAllText("./" + filename + ".csv", it.KeyAsString().Replace("Storages___", "") + "," + json + "\n"); } else if (it.KeyAsString().Contains("StgMap")) { Console.WriteLine($"Value as string: {it.ValueAsString()}"); File.AppendAllText("./" + filename + ".csv", $"{it.KeyAsString()},{it.ValueAsString()}\n"); } } } File.AppendAllText("./" + filename + ".csv", "All" + "," + sum + "\n"); long posProduct = 0; long powProduct = 0; long posOriginally = 0; long powOriginally = 0; for (long i = 1; i <= height; i++) { Block block = BlockChainHelper.GetMcBlock(i); long posNodeCount = block.linksblk.Count; posProduct += posNodeCount * Consensus.GetRewardRule(i); powProduct += Consensus.GetReward(i); posOriginally += 25 * Consensus.GetRewardRule(i); powOriginally += Consensus.GetReward(i); } long All_Product = posProduct + powProduct; File.AppendAllText("./" + filename + ".csv", "All_Product" + "," + All_Product + "\n"); File.AppendAllText("./" + filename + ".csv", "posProduct" + "," + posProduct + "\n"); File.AppendAllText("./" + filename + ".csv", "posOriginally" + "," + posOriginally + "\n"); File.AppendAllText("./" + filename + ".csv", "powOriginally" + "," + powOriginally + "\n"); Console.WriteLine("导出完成"); } } }