OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
agent/runners/lua/impl.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNER_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNER_H_
8
10#include "parsec/util.hpp"
11
12#include <lua.hpp>
13#include <memory>
14
25 class lua_runner : public interface {
26 public:
28 lua_runner(std::shared_ptr<logging::log> logger,
29 const cbdc::parsec::config& cfg,
31 parameter_type param,
32 bool is_readonly_run,
33 run_callback_type result_callback,
34 try_lock_callback_type try_lock_callback,
35 std::shared_ptr<secp256k1_context> secp,
36 std::shared_ptr<thread_pool> t_pool,
37 ticket_number_type ticket_number);
38
42 [[nodiscard]] auto run() -> bool override;
43
45 static constexpr auto initial_lock_type = broker::lock_type::read;
46
47 private:
48 std::shared_ptr<lua_State> m_state;
49
50 void contract_epilogue(int n_results);
51
52 auto get_stack_string(int index) -> std::optional<buffer>;
53
54 auto get_stack_integer(int index) -> std::optional<int64_t>;
55
56 void schedule_contract();
57
58 void
59 handle_try_lock(const broker::interface::try_lock_return_type& res);
60
61 static auto check_sig(lua_State* L) -> int;
62 };
63}
64
65#endif
Buffer to store and retrieve byte data.
Definition buffer.hpp:15
std::function< void(run_return_type)> run_callback_type
Callback type for function execution.
std::function< bool(broker::key_type, broker::lock_type, broker::interface::try_lock_callback_type)> try_lock_callback_type
Callback function type for acquiring locks during function execution.
parsec::ticket_machine::ticket_number_type ticket_number_type
Type alias for a ticket number.
static constexpr auto initial_lock_type
Lock type to acquire when requesting the function code.
auto run() -> bool override
Begins function execution.
std::variant< value_type, error_code, runtime_locking_shard::shard_error > try_lock_return_type
Return type from a try lock operation.
Configuration parameters for a phase two system.