OpenCBDC Transaction Processor
|
Lua function executor. More...
#include <impl.hpp>
Public Member Functions | |
lua_runner (std::shared_ptr< logging::log > logger, const cbdc::parsec::config &cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, run_callback_type result_callback, try_lock_callback_type try_lock_callback, std::shared_ptr< secp256k1_context > secp, std::shared_ptr< thread_pool > t_pool, ticket_number_type ticket_number) | |
Constructor. | |
auto | run () -> bool override |
Begins function execution. | |
![]() | |
interface (std::shared_ptr< logging::log > logger, const cbdc::parsec::config &cfg, runtime_locking_shard::value_type function, parameter_type param, bool is_readonly_run, run_callback_type result_callback, try_lock_callback_type try_lock_callback, std::shared_ptr< secp256k1_context > secp, std::shared_ptr< thread_pool > t_pool, ticket_number_type ticket_number) | |
Constructor. | |
virtual | ~interface ()=default |
interface (const interface &)=delete | |
auto | operator= (const interface &) -> interface &=delete |
interface (interface &&)=delete | |
auto | operator= (interface &&) -> interface &=delete |
Static Public Attributes | |
static constexpr auto | initial_lock_type = broker::lock_type::read |
Lock type to acquire when requesting the function code. | |
Additional Inherited Members | |
![]() | |
enum class | error_code { result_value_type , result_key_type , result_type , result_count , exec_error , function_load , internal_error , yield_count , yield_type , lock_error , wounded } |
Error codes return during function execution. More... | |
using | ticket_number_type = parsec::ticket_machine::ticket_number_type |
Type alias for a ticket number. | |
using | run_return_type |
Return type from executing a function. | |
using | run_callback_type = std::function<void(run_return_type)> |
Callback type for function execution. | |
using | try_lock_callback_type |
Callback function type for acquiring locks during function execution. | |
using | factory_type |
Factory function type for instantiating new runners. | |
Lua function executor.
Provides an environment for contracts to execute in. Manages retrieval of function bytecode, locking keys during function execution, signature checking and commiting execution results. Class cannot be re-used for different functions/transactions, manages the lifecycle of a single transaction. NOTE: When writing contracts, to pass data between the Lua environment and the C++ environment, use coroutine.yield()
. To request a read-lock use coroutine.yield(<data>, 0). To request a write-lock use coroutine.yield(<data>, 1) or coroutine.yield(<data>).
Definition at line 25 of file agent/runners/lua/impl.hpp.
cbdc::parsec::agent::runner::lua_runner::lua_runner | ( | std::shared_ptr< logging::log > | logger, |
const cbdc::parsec::config & | cfg, | ||
runtime_locking_shard::value_type | function, | ||
parameter_type | param, | ||
bool | is_readonly_run, | ||
run_callback_type | result_callback, | ||
try_lock_callback_type | try_lock_callback, | ||
std::shared_ptr< secp256k1_context > | secp, | ||
std::shared_ptr< thread_pool > | t_pool, | ||
ticket_number_type | ticket_number ) |
Constructor.
logger | log instance. |
cfg | config reference. |
function | key of function bytecode to execute. |
param | parameter to pass to function. |
is_readonly_run | true if runner execution should not result in state changes. |
result_callback | function to call with function execution result. |
try_lock_callback | function to call for the function to request key locks. |
secp | shared context for libsecp256k1. |
t_pool | shared thread pool between agents. |
ticket_number | ticket number for the ticket managed by this runner instance. |
Definition at line 23 of file agent/runners/lua/impl.cpp.
|
nodiscardoverridevirtual |
Begins function execution.
Retrieves the function bytecode using a read lock and executes it with the given parameter.
Implements cbdc::parsec::agent::runner::interface.
Definition at line 44 of file agent/runners/lua/impl.cpp.
|
staticconstexpr |
Lock type to acquire when requesting the function code.
Definition at line 45 of file agent/runners/lua/impl.hpp.