Пример #1
0
        public static void LoadBlocks()
        {
            using (StreamReader reader = new StreamReader("../../../block.txt"))
            {
                string line;
                int    count = 0;
                while (null != (line = reader.ReadLine()))
                {
                    JSONBack  jsonBack = ConvertToJSONBack(line);
                    List <In> ins      = new List <In>();
                    foreach (Input _in in jsonBack.ins)
                    {
                        In __in = new In(_in.addr, _in.tx_index);
                        ins.Add(__in);
                    }
                    try
                    {
                        Tx tx = new Tx(jsonBack.CellID, jsonBack.time, jsonBack.hash, ins, jsonBack.outs, jsonBack.amount, Convert.ToBoolean(jsonBack.isAmount), Convert.ToBoolean(jsonBack.isFreq), Convert.ToBoolean(jsonBack.isCycle));
                        Global.LocalStorage.SaveTx(tx);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.ToString());
                        throw;
                    }

                    count++;
                }
                Console.WriteLine(count);
            }
        }
Пример #2
0
        public static JSONBack ConvertToJSONBack(string jsonStr)
        {
            JSONBack JSONBack = new JSONBack();

            try
            {
                JSONBack = JsonConvert.DeserializeObject <JSONBack>(jsonStr);
            }
            catch (Exception e)
            {
                return(null);
            }
            return(JSONBack);
        }