Beispiel #1
0
 public void OnPersist(StoreView snapshot, IReadOnlyList <Blockchain.ApplicationExecuted> applicationExecutedList)
 {
     foreach (var appExec in applicationExecutedList.Where(e => e.Transaction != null))
     {
         var execResult = new ExecuteResultInfo();
         execResult.TxId        = appExec.Transaction.Hash.ToString();
         execResult.Trigger     = appExec.Trigger;
         execResult.VMState     = appExec.VMState;
         execResult.GasConsumed = appExec.GasConsumed;
         try
         {
             execResult.ResultStack = appExec.Stack.Select(q => q.ToParameter().ToJson()).ToArray();
         }
         catch (InvalidOperationException)
         {
             execResult.ResultStack = "error: recursive reference";
         }
         execResult.Notifications = appExec.Notifications.Select(q =>
         {
             var notification      = new NotificationInfo();
             notification.Contract = q.ScriptHash.ToString();
             try
             {
                 notification.State = q.State.ToParameter().ToJson();
             }
             catch (InvalidOperationException)
             {
                 notification.State = "error: recursive reference";
             }
             return(notification);
         }).ToList();
         _db.AddExecuteLog(appExec.Transaction.Hash, execResult);
     }
 }