OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::locking_shard::rpc::status_client Class Reference

Client for interacting with the read-only port on 2PC shards. More...

#include <status_client.hpp>

Inheritance diagram for cbdc::locking_shard::rpc::status_client:
Collaboration diagram for cbdc::locking_shard::rpc::status_client:

Public Member Functions

 status_client (std::vector< std::vector< network::endpoint_t > > shard_read_only_endpoints, std::vector< config::shard_range_t > shard_ranges, std::chrono::milliseconds timeout=std::chrono::milliseconds::zero())
 Constructor.
 
 ~status_client () override=default
 Destructor.
 
 status_client ()=delete
 
 status_client (const status_client &)=delete
 
auto operator= (const status_client &) -> status_client &=delete
 
 status_client (status_client &&)=delete
 
auto operator= (status_client &&) -> status_client &=delete
 
auto init () -> bool
 Initializes the client by creating a TCP RPC client for each shard cluster.
 
auto check_unspent (const hash_t &uhs_id) -> std::optional< bool > override
 Queries the shard cluster responsible for the given UHS ID for whether it is unspent.
 
auto check_tx_id (const hash_t &tx_id) -> std::optional< bool > override
 Queries the shard cluster responsible for the given TX ID for whether it is in the confirmed TX IDs cache.
 
- Public Member Functions inherited from cbdc::locking_shard::status_interface
 status_interface ()=default
 
virtual ~status_interface ()=default
 
 status_interface (const status_interface &)=default
 
auto operator= (const status_interface &) -> status_interface &=default
 
 status_interface (status_interface &&)=default
 
auto operator= (status_interface &&) -> status_interface &=default
 

Detailed Description

Client for interacting with the read-only port on 2PC shards.

Allows for checking whether a TX ID has been confirmed or whether a UHS ID is currently unspent. Connects to all shard nodes to handle failover and routes requests to the relevant shard.

Definition at line 19 of file status_client.hpp.

Constructor & Destructor Documentation

◆ status_client() [1/4]

cbdc::locking_shard::rpc::status_client::status_client ( std::vector< std::vector< network::endpoint_t > > shard_read_only_endpoints,
std::vector< config::shard_range_t > shard_ranges,
std::chrono::milliseconds timeout = std::chrono::milliseconds::zero() )

Constructor.

Parameters
shard_read_only_endpointslist of endpoints by shard ID then node ID.
shard_rangeslist of shard hash prefix ranges by shard ID. Must be the same size as shard_read_only_endpoints.
timeoutoptional timeout for status requests. Zero indicates no timeout.

Definition at line 11 of file status_client.cpp.

◆ ~status_client()

cbdc::locking_shard::rpc::status_client::~status_client ( )
overridedefault

Destructor.

◆ status_client() [2/4]

cbdc::locking_shard::rpc::status_client::status_client ( )
delete

◆ status_client() [3/4]

cbdc::locking_shard::rpc::status_client::status_client ( const status_client & )
delete

◆ status_client() [4/4]

cbdc::locking_shard::rpc::status_client::status_client ( status_client && )
delete

Member Function Documentation

◆ check_tx_id()

auto cbdc::locking_shard::rpc::status_client::check_tx_id ( const hash_t & tx_id) -> std::optional<bool>
nodiscardoverridevirtual

Queries the shard cluster responsible for the given TX ID for whether it is in the confirmed TX IDs cache.

Parameters
tx_idTX ID to query.
Returns
true if the cache contains the TX ID, or std::nullopt if the request failed.

Implements cbdc::locking_shard::status_interface.

Definition at line 37 of file status_client.cpp.

◆ check_unspent()

auto cbdc::locking_shard::rpc::status_client::check_unspent ( const hash_t & uhs_id) -> std::optional<bool>
nodiscardoverridevirtual

Queries the shard cluster responsible for the given UHS ID for whether it is unspent.

Parameters
uhs_idUHS ID to query.
Returns
true if the UHS ID is unspent, or std::nullopt if the request failed.

Implements cbdc::locking_shard::status_interface.

Definition at line 42 of file status_client.cpp.

◆ init()

auto cbdc::locking_shard::rpc::status_client::init ( ) -> bool

Initializes the client by creating a TCP RPC client for each shard cluster.

Returns
true if the RPC clients initialized successfully.

Definition at line 28 of file status_client.cpp.

References cbdc::locking_shard::rpc::client::init().

Here is the call graph for this function:

◆ operator=() [1/2]

auto cbdc::locking_shard::rpc::status_client::operator= ( const status_client & ) -> status_client &=delete
delete

◆ operator=() [2/2]

auto cbdc::locking_shard::rpc::status_client::operator= ( status_client && ) -> status_client &=delete
delete

References cbdc::config::hash_in_shard_range().

Here is the call graph for this function:

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