private RunTime(Transaction tx, BlockCapsule block, Deposit deposit, IProgramInvokeFactory invoke_factory) { this.transaction = tx; this.deposit = deposit; this.invoke_factory = invoke_factory; this.executor_type = ExecutorType.ET_PRE_TYPE; this.block = block; this.energy_processor = new EnergyProcessor(deposit.DBManager); ContractType contract_type = tx.RawData.Contract[0].Type; switch (contract_type) { case ContractType.TriggerSmartContract: { this.transaction_type = TransactionType.TX_CONTRACT_CALL_TYPE; } break; case ContractType.CreateSmartContract: { this.transaction_type = TransactionType.TX_CONTRACT_CREATION_TYPE; } break; default: { this.transaction_type = TransactionType.TX_PRECOMPILED_TYPE; } break; } }
public InternalTransaction(Transaction tx, InternalTransaction.TransactionType tx_type) { this.transaction = tx; TransactionCapsule transaction = new TransactionCapsule(tx); this.proto_encoded = transaction.Data; this.nonce = 0; this.deep = -1; if (tx_type == TransactionType.TX_CONTRACT_CREATION_TYPE) { CreateSmartContract contract = ContractCapsule.GetSmartContractFromTransaction(tx); if (contract == null) { throw new ContractValidateException("Invalid CreateSmartContract protocol"); } this.send_address = contract.OwnerAddress.ToByteArray(); this.receive_address = new byte[0]; this.transfer_to_address = Wallet.GenerateContractAddress(tx); this.note = "create"; this.value = contract.NewContract.CallValue; this.data = contract.NewContract.Bytecode.ToByteArray(); this.token_info.Add(contract.TokenId.ToString(), contract.CallTokenValue); } else if (tx_type == TransactionType.TX_CONTRACT_CALL_TYPE) { TriggerSmartContract contract = ContractCapsule.GetTriggerContractFromTransaction(tx); if (contract == null) { throw new ContractValidateException("Invalid TriggerSmartContract protocol"); } this.send_address = contract.OwnerAddress.ToByteArray(); this.receive_address = contract.ContractAddress.ToByteArray(); this.transfer_to_address = (byte[])this.receive_address.Clone(); this.note = "call"; this.value = contract.CallValue; this.data = contract.Data.ToByteArray(); this.token_info.Add(contract.TokenId.ToString(), contract.CallTokenValue); } this.hash = transaction.Id.Hash; }
public RunTime(TransactionTrace trace, BlockCapsule block, Deposit deposit, IProgramInvokeFactory invoke_factory) { this.trace = trace; this.transaction = trace.Transaction.Instance; if (block != null) { this.block = block; this.executor_type = ExecutorType.ET_NORMAL_TYPE; } else { this.block = new BlockCapsule(new Block()); this.executor_type = ExecutorType.ET_PRE_TYPE; } this.deposit = deposit; this.invoke_factory = invoke_factory; this.energy_processor = new EnergyProcessor(deposit.DBManager); ContractType contract_type = this.transaction.RawData.Contract[0].Type; switch (contract_type) { case ContractType.TriggerSmartContract: { this.transaction_type = TransactionType.TX_CONTRACT_CALL_TYPE; } break; case ContractType.CreateSmartContract: { this.transaction_type = TransactionType.TX_CONTRACT_CREATION_TYPE; } break; default: { this.transaction_type = TransactionType.TX_PRECOMPILED_TYPE; } break; } }
public TransactionTrace(TransactionCapsule tx, DatabaseManager db_manager) { this.transaction = tx; this.db_manager = db_manager; this.receipt = new ReceiptCapsule(SHA256Hash.ZERO_HASH); this.energy_processor = new EnergyProcessor(this.db_manager); ContractType contract_type = this.transaction.Instance.RawData.Contract[0].Type; switch (contract_type) { case ContractType.TriggerSmartContract: this.transaction_type = InternalTransaction.TransactionType.TX_CONTRACT_CALL_TYPE; break; case ContractType.CreateSmartContract: this.transaction_type = InternalTransaction.TransactionType.TX_CONTRACT_CREATION_TYPE; break; default: this.transaction_type = InternalTransaction.TransactionType.TX_PRECOMPILED_TYPE; break; } }