/// <summary> /// Executes contracts as necessary and updates the coinview / UTXOset after execution. /// </summary> /// <inheritdoc/> public void UpdateCoinView(Action <RuleContext, Transaction> baseUpdateUTXOSet, RuleContext context, Transaction transaction) { if (this.generatedTransaction != null) { ValidateGeneratedTransaction(transaction); baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); return; } // If we are here, was definitely submitted by someone ValidateSubmittedTransaction(transaction); TxOut smartContractTxOut = transaction.Outputs.FirstOrDefault(txOut => SmartContractScript.IsSmartContractExec(txOut.ScriptPubKey)); if (smartContractTxOut == null) { // Someone submitted a standard transaction - no smart contract opcodes. baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); return; } // Someone submitted a smart contract transaction. ExecuteContractTransaction(context, transaction); baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); }
/// <summary> /// Executes contracts as necessary and updates the coinview / UTXOset after execution. /// </summary> public void UpdateCoinView(Action <RuleContext, Transaction> baseUpdateUTXOSet, RuleContext context, Transaction transaction) { // We already have results for this block. No need to do any processing other than updating the UTXO set. if (this.cachedResults != null) { baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); return; } if (this.generatedTransaction != null) { this.ValidateGeneratedTransaction(transaction); baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); return; } // If we are here, was definitely submitted by someone this.ValidateSubmittedTransaction(transaction); TxOut smartContractTxOut = transaction.Outputs.FirstOrDefault(txOut => SmartContractScript.IsSmartContractExec(txOut.ScriptPubKey)); if (smartContractTxOut == null) { // Someone submitted a standard transaction - no smart contract opcodes. baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); return; } // Someone submitted a smart contract transaction. this.ExecuteContractTransaction(context, transaction); baseUpdateUTXOSet(context, transaction); this.blockTxsProcessed.Add(transaction); }