OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::sentinel::rpc::client Class Reference

TCP RPC client for sentinels. More...

#include <client.hpp>

Inheritance diagram for cbdc::sentinel::rpc::client:
Collaboration diagram for cbdc::sentinel::rpc::client:

Public Types

using execute_result_type = std::optional<cbdc::sentinel::execute_response>
 Result type from execute_transaction.
 
using validate_result_type = std::optional<validate_response>
 Return type from transaction validation.
 
- 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.
 

Public Member Functions

 client (std::vector< network::endpoint_t > endpoints, std::shared_ptr< logging::log > logger)
 Constructor.
 
 ~client () override=default
 
 client ()=delete
 
 client (const client &)=delete
 
auto operator= (const client &) -> client &=delete
 
 client (client &&)=delete
 
auto operator= (client &&) -> client &=delete
 
auto init (std::optional< bool > error_fatal=std::nullopt) -> bool
 Initializes the client.
 
auto execute_transaction (transaction::full_tx tx) -> execute_result_type override
 Send a transaction to the sentinel and return the response.
 
auto execute_transaction (transaction::full_tx tx, std::function< void(execute_result_type)> result_callback) -> bool override
 Send a transaction to the sentinel and return the response via a callback function asynchronously.
 
auto validate_transaction (transaction::full_tx tx) -> validate_result_type override
 Send a transaction to the sentinel for validation and return the response.
 
auto validate_transaction (transaction::full_tx tx, std::function< void(validate_result_type)> result_callback) -> bool override
 Send a transaction to the sentinel for validation and return the response via a callback function asynchronously.
 
- Public Member Functions inherited from cbdc::sentinel::interface
virtual ~interface ()=default
 
 interface ()=default
 
 interface (const interface &)=delete
 
auto operator= (const interface &) -> interface &=delete
 
 interface (interface &&)=delete
 
auto operator= (interface &&) -> interface &=delete
 
- 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
 
virtual auto validate_transaction (transaction::full_tx tx, validate_result_callback_type result_callback) -> bool=0
 Statically validate the given transaction and generate a sentinel attestation if the transaction is valid.
 

Detailed Description

TCP RPC client for sentinels.

Definition at line 17 of file uhs/sentinel/client.hpp.

Member Typedef Documentation

◆ execute_result_type

Result type from execute_transaction.

Definition at line 41 of file uhs/sentinel/client.hpp.

◆ validate_result_type

Return type from transaction validation.

Definition at line 60 of file uhs/sentinel/client.hpp.

Constructor & Destructor Documentation

◆ client() [1/4]

cbdc::sentinel::rpc::client::client ( std::vector< network::endpoint_t > endpoints,
std::shared_ptr< logging::log > logger )

Constructor.

Parameters
endpointssentinel cluster RPC endpoints.
loggerpointer shared logger.

Definition at line 13 of file uhs/sentinel/client.cpp.

◆ ~client()

cbdc::sentinel::rpc::client::~client ( )
overridedefault

◆ client() [2/4]

cbdc::sentinel::rpc::client::client ( )
delete

◆ client() [3/4]

cbdc::sentinel::rpc::client::client ( const client & )
delete

◆ client() [4/4]

cbdc::sentinel::rpc::client::client ( client && )
delete

Member Function Documentation

◆ execute_transaction() [1/2]

auto cbdc::sentinel::rpc::client::execute_transaction ( transaction::full_tx tx) -> execute_result_type
overridevirtual

Send a transaction to the sentinel and return the response.

Parameters
txtransaction to send to the sentinel.
Returns
the response from the sentinel.

Implements cbdc::sentinel::interface.

Definition at line 26 of file uhs/sentinel/client.cpp.

◆ execute_transaction() [2/2]

auto cbdc::sentinel::rpc::client::execute_transaction ( transaction::full_tx tx,
std::function< void(execute_result_type)> result_callback ) -> bool
overridevirtual

Send a transaction to the sentinel and return the response via a callback function asynchronously.

Parameters
txtransaction to send to the sentinel.
result_callbackcallback function to call with the result.
Returns
true if the request was sent successfully.

Implements cbdc::sentinel::async_interface.

Definition at line 35 of file uhs/sentinel/client.cpp.

◆ init()

auto cbdc::sentinel::rpc::client::init ( std::optional< bool > error_fatal = std::nullopt) -> bool

Initializes the client.

Establishes a connection to the sentinel.

Parameters
error_fataltreat connection errors as fatal. See tcp_client::init for further explanation.
Returns
true if initialization succeeded.
See also
cbdc::rpc::tcp_client::init(std::optional<bool>)

Definition at line 18 of file uhs/sentinel/client.cpp.

◆ operator=() [1/2]

auto cbdc::sentinel::rpc::client::operator= ( client && ) -> client &=delete
delete

◆ operator=() [2/2]

auto cbdc::sentinel::rpc::client::operator= ( const client & ) -> client &=delete
delete

◆ validate_transaction() [1/2]

auto cbdc::sentinel::rpc::client::validate_transaction ( transaction::full_tx tx) -> validate_result_type
overridevirtual

Send a transaction to the sentinel for validation and return the response.

Parameters
txtransaction to validate and attest to.
Returns
sentinel attestation on the given transaction or std::nullopt if the transaction was invalid.

Implements cbdc::sentinel::interface.

Definition at line 49 of file uhs/sentinel/client.cpp.

◆ validate_transaction() [2/2]

auto cbdc::sentinel::rpc::client::validate_transaction ( transaction::full_tx tx,
std::function< void(validate_result_type)> result_callback ) -> bool
override

Send a transaction to the sentinel for validation and return the response via a callback function asynchronously.

Parameters
txtransaction to validate and attest to.
result_callbackcallback function to call with the result.
Returns
true if the request was sent successfully.

Definition at line 58 of file uhs/sentinel/client.cpp.


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