OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::sentinel_2pc::controller Class Reference

Manages a sentinel server for the two-phase commit architecture. More...

#include <controller.hpp>

Inheritance diagram for cbdc::sentinel_2pc::controller:
Collaboration diagram for cbdc::sentinel_2pc::controller:

Public Member Functions

 controller ()=delete
 
 controller (const controller &)=delete
 
auto operator= (const controller &) -> controller &=delete
 
 controller (controller &&)=delete
 
auto operator= (controller &&) -> controller &=delete
 
 controller (uint32_t sentinel_id, const config::options &opts, std::shared_ptr< logging::log > logger)
 Constructor.
 
 ~controller () override=default
 
auto init () -> bool
 Initializes the controller.
 
auto execute_transaction (transaction::full_tx tx, execute_result_callback_type result_callback) -> bool override
 Statically validates a transaction, submits it the shard coordinator network, and returns the result via a callback function.
 
auto validate_transaction (transaction::full_tx tx, validate_result_callback_type result_callback) -> bool override
 Statically validates a transaction and generates a sentinel attestation if the transaction is valid.
 
- Public Member Functions inherited from cbdc::sentinel::async_interface
virtual ~async_interface ()=default
 
 async_interface ()=default
 
 async_interface (const async_interface &)=delete
 
auto operator= (const async_interface &) -> async_interface &=delete
 
 async_interface (async_interface &&)=delete
 
auto operator= (async_interface &&) -> async_interface &=delete
 

Additional Inherited Members

- Public Types inherited from cbdc::sentinel::async_interface
using result_callback_type = std::function<void(std::optional<cbdc::sentinel::response>)>
 Callback function for a sentinel response.
 
using execute_result_callback_type
 Callback function for transaction execution result.
 
using validate_result = std::optional<cbdc::sentinel::validate_response>
 Result of a validation operation.
 
using validate_result_callback_type = std::function<void(validate_result)>
 Callback function for providing a transaction validation result.
 

Detailed Description

Manages a sentinel server for the two-phase commit architecture.

Definition at line 24 of file uhs/twophase/sentinel_2pc/controller.hpp.

Constructor & Destructor Documentation

◆ controller() [1/4]

cbdc::sentinel_2pc::controller::controller ( )
delete

◆ controller() [2/4]

cbdc::sentinel_2pc::controller::controller ( const controller & )
delete

◆ controller() [3/4]

cbdc::sentinel_2pc::controller::controller ( controller && )
delete

◆ controller() [4/4]

cbdc::sentinel_2pc::controller::controller ( uint32_t sentinel_id,
const config::options & opts,
std::shared_ptr< logging::log > logger )

Constructor.

Parameters
sentinel_idthe running ID of this shard.
optspointer to configuration options.
loggerpointer shared logger.

Definition at line 15 of file uhs/twophase/sentinel_2pc/controller.cpp.

◆ ~controller()

cbdc::sentinel_2pc::controller::~controller ( )
overridedefault

Member Function Documentation

◆ execute_transaction()

auto cbdc::sentinel_2pc::controller::execute_transaction ( transaction::full_tx tx,
execute_result_callback_type result_callback ) -> bool
overridevirtual

Statically validates a transaction, submits it the shard coordinator network, and returns the result via a callback function.

Parameters
txtransaction to submit.
result_callbackfunction to call with the execution result.
Returns
false if the sentinel was unable to forward the transaction to a coordinator.

Implements cbdc::sentinel::async_interface.

Definition at line 98 of file uhs/twophase/sentinel_2pc/controller.cpp.

References cbdc::transaction::validation::check_tx(), cbdc::sentinel::static_invalid, cbdc::to_string(), cbdc::transaction::validation::to_string(), and cbdc::transaction::tx_id().

Here is the call graph for this function:

◆ init()

auto cbdc::sentinel_2pc::controller::init ( ) -> bool

Initializes the controller.

Connects to the shard coordinator network and launches a server thread for external clients.

Returns
true if initialization succeeded.

Definition at line 27 of file uhs/twophase/sentinel_2pc/controller.cpp.

References cbdc::client::init(), cbdc::pubkey_from_privkey(), and cbdc::to_string().

Here is the call graph for this function:

◆ operator=() [1/2]

auto cbdc::sentinel_2pc::controller::operator= ( const controller & ) -> controller &=delete
delete

◆ operator=() [2/2]

auto cbdc::sentinel_2pc::controller::operator= ( controller && ) -> controller &=delete
delete

◆ validate_transaction()

auto cbdc::sentinel_2pc::controller::validate_transaction ( transaction::full_tx tx,
validate_result_callback_type result_callback ) -> bool
overridevirtual

Statically validates a transaction and generates a sentinel attestation if the transaction is valid.

Parameters
txtransaction to validate.
result_callbackfunction to call with the attestation or std::nullopt if the transaction was invalid.
Returns
true.

Implements cbdc::sentinel::async_interface.

Definition at line 143 of file uhs/twophase/sentinel_2pc/controller.cpp.

References cbdc::transaction::validation::check_tx().

Here is the call graph for this function:

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