OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::parsec::agent::runner::interface Class Referenceabstract

Interface for a contract runner. More...

#include <interface.hpp>

Inheritance diagram for cbdc::parsec::agent::runner::interface:

Public Types

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.
 

Public Member Functions

 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
 
virtual auto run () -> bool=0
 Begins function execution.
 

Friends

class lua_runner
 
class evm_runner
 

Detailed Description

Interface for a contract runner.

Subclasses should implement application logic to enforce specific transaction semantics.

Definition at line 21 of file parsec/agent/runners/interface.hpp.

Member Typedef Documentation

◆ factory_type

Initial value:
std::function<std::unique_ptr<interface>(
std::shared_ptr<logging::log> logger,
bool is_readonly_run,
std::shared_ptr<secp256k1_context>,
std::shared_ptr<thread_pool> t_pool,
ticket_number_type ticket_number)>
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.
buffer parameter_type
Type of function call parameter.
Configuration parameters for a phase two system.

Factory function type for instantiating new runners.

Definition at line 67 of file parsec/agent/runners/interface.hpp.

◆ run_callback_type

Callback type for function execution.

Definition at line 57 of file parsec/agent/runners/interface.hpp.

◆ run_return_type

Initial value:
error_code
Error codes return during function execution.
std:: unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_update_type
Type for state updates to a shard. A map of keys and their new values.

Return type from executing a function.

Either the state updates committed after function execution or an error code.

Definition at line 54 of file parsec/agent/runners/interface.hpp.

◆ ticket_number_type

◆ try_lock_callback_type

Initial value:
std::function<bool(broker::key_type,
std::function< void(try_lock_return_type)> try_lock_callback_type
Callback function type for a try lock operation.
runtime_locking_shard::key_type key_type
Shard key type.
runtime_locking_shard::lock_type lock_type
Shard lock type.

Callback function type for acquiring locks during function execution.

Accepts a key to lock and function to call with lock result. Returns true if request was initiated successfully.

Definition at line 62 of file parsec/agent/runners/interface.hpp.

Member Enumeration Documentation

◆ error_code

Error codes return during function execution.

Enumerator
result_value_type 

Function did not return a string value.

result_key_type 

Function did not return a string key.

result_type 

Function did not return a map.

result_count 

Function more than one result.

exec_error 

Runner error during function execution.

function_load 

Error loading function bytecode.

internal_error 

Internal Runner error.

yield_count 

Function yielded more than one key to lock.

yield_type 

Function yielded a invalid datatype.

lock_error 

Error acquiring lock on key.

wounded 

Ticket wounded during execution.

Definition at line 24 of file parsec/agent/runners/interface.hpp.

Constructor & Destructor Documentation

◆ interface() [1/3]

cbdc::parsec::agent::runner::interface::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.

Parameters
loggerlog instance.
cfgconfig reference.
functionkey of function bytecode to execute.
paramparameter to pass to function.
is_readonly_runtrue if runner execution should not result in state changes.
result_callbackfunction to call with function execution result.
try_lock_callbackfunction to call for the function to request key locks.
secpshared context for libsecp256k1.
t_poolshared thread pool between agents.
ticket_numberticket number for the ticket managed by this runner instance.

Definition at line 9 of file parsec/agent/runners/interface.cpp.

◆ ~interface()

virtual cbdc::parsec::agent::runner::interface::~interface ( )
virtualdefault

◆ interface() [2/3]

cbdc::parsec::agent::runner::interface::interface ( const interface & )
delete

◆ interface() [3/3]

cbdc::parsec::agent::runner::interface::interface ( interface && )
delete

Member Function Documentation

◆ operator=() [1/2]

auto cbdc::parsec::agent::runner::interface::operator= ( const interface & ) -> interface &=delete
delete

◆ operator=() [2/2]

auto cbdc::parsec::agent::runner::interface::operator= ( interface && ) -> interface &=delete
delete

◆ run()

virtual auto cbdc::parsec::agent::runner::interface::run ( ) -> bool
nodiscardpure virtual

Begins function execution.

Retrieves the function bytecode using a read lock and executes it with the given parameter.

Returns
true unless a internal system error has occurred

Implemented in cbdc::parsec::agent::runner::evm_runner, and cbdc::parsec::agent::runner::lua_runner.

Friends And Related Symbol Documentation

◆ evm_runner

friend class evm_runner
friend

Definition at line 118 of file parsec/agent/runners/interface.hpp.

◆ lua_runner

friend class lua_runner
friend

Definition at line 117 of file parsec/agent/runners/interface.hpp.


The documentation for this class was generated from the following files: