Пример #1
0
        public static TransactionVmStack CreateTransactionVmStack(string transactionHash,
                                                                  string address,
                                                                  JObject stack)
        {
            var structsLogs        = (JArray)stack["structLogs"];
            var transactionVmStack = new TransactionVmStack()
            {
                TransactionHash = transactionHash,
                Address         = address
            };

            transactionVmStack.InitStruct(structsLogs);
            return(transactionVmStack);
        }
        //public async Task UpsertAsync(string transactionHash,
        //    string address,
        //    JObject stackTrace)
        //{
        //  var entity = TransactionVmStack.CreateTransactionVmStack(transactionHash, address, stackTrace);
        //  await InsertOrUpdate(entity);
        //}

        public async Task InsertOrUpdate(TransactionVmStack stack)
        {
            using (var context = new BlockchainStoreContext())
            {
                //context.Entry(stack).State = string.IsNullOrEmpty(stack.TransactionHash) ?
                //                           EntityState.Added :
                //                           EntityState.Modified;

                try
                {
                    context.TransactionVmStacks.Add(stack);
                    await context.SaveChangesAsync();
                }
                catch (System.Exception)
                {
                }
            }
        }