Published 15 October 2018

TransactionFlow

Processing the transaction with specified inputs.

Parameters

Parameters:

1: Transaction transaction

Type of result: TransactionFlowResult

Operation algorithm

Operation algorithm:

Address source is recoded: if the address string length is 64 symbols, then we re-code from 16 representation into string, or else we compute the public key hash in respect of the same based on the blake2s algorithm.

We determine the transaction object with field values from the inbound transaction.

If the transaction specifies the smart contract address, then we:

Update the smart contract cache:

Obtain the last block’s hash value.

Set the current hash's variable equal to the last block’s hash value.

While the current hash's variable is not equal to the hash value of the block last viewed by the smart contract, we:

Download the block containing the current hash to the pool.

Retrieve the smart contract in respect of all transactions.

Complete class structures from the smart contract. If the current transaction unrolls the smart contract, then we cache transaction ID, sender, recipient or else save the smart contract address and ID.

Move the current hash's variable to the previous block.

We set the hash value of the block last viewed by the smart contract equal to the last block’s hash value.

We retrieve the transaction's smart contract from the cache memory of the transactions being unrolled by sender.

We retrieve the transaction's smart contract from the cache memory of executable transactions by sender.

If the smart contract unrolling is required, then we retrieve from the smart contract its byte code, source code, address target, hash state, method and parameters or else we quit the function in the FAILURE status.

If the smart contract is specified, we add the serialized structure of the smart contract being unrolled to the structure of the transaction being processed.

We submit the transaction for processing.

Unless the smart contract is specified, we quit the function in the SUCCESS status.

We open transport protocol for connections.

We execute the smart contract's byte code using the executor.

We add to the structure of the transaction being processed the new smart contract having its status as “executed” during the previous step of the smart contract, its method, parameters, address and submit the transaction for processing.

We quit the function in the SUCCESS status.

Data structure

The following structures are used for marshalling purposes:

TransactionFlowResult transaction processing result

typedef binary PoolHash

typedef i64 PoolNumber

typedef i64 Time

typedef i32 Count

APIResponse status

status

i8 code //status code

string message //status communication

Example

Example

/** TransactionFlow begin */

 

Transaction                       tr;

TransactionFlowResult    tf_res;

 

try

{

         api->TransactionFlow(tf_res, tr);

}

catch (...)

{

         return 1;

}

 

tf_res.printTo(std::cout);

std::cout << std::endl << std::endl;

 

/** TransactionFlow end */

15 Useful article

Contents