OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::locking_shard::rpc::client Class Referencefinal

RPC client for the mutable interface to a locking shard raft cluster. More...

#include <client.hpp>

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

Public Member Functions

 client (std::vector< network::endpoint_t > endpoints, const std::pair< uint8_t, uint8_t > &output_range, logging::log &logger)
 Constructs a new locking shard client for issuing RPCs to a remote shard cluster.
 
 client ()=delete
 
 ~client () override
 
 client (const client &)=delete
 
auto operator= (const client &) -> client &=delete
 
 client (client &&)=delete
 
auto operator= (client &&) -> client &=delete
 
auto init () -> bool
 Initializes the RPC client.
 
auto lock_outputs (std::vector< tx > &&txs, const hash_t &dtx_id) -> std::optional< std::vector< bool > > override
 Issues a lock RPC to the remote shard and returns its response.
 
auto apply_outputs (std::vector< bool > &&complete_txs, const hash_t &dtx_id) -> bool override
 Issues an apply RPC to the remote shard and returns its response.
 
auto discard_dtx (const hash_t &dtx_id) -> bool override
 Issues a discard RPC to the remote shard and returns its response.
 
void stop () override
 Shuts down the client and unblocks any existing requests waiting for a response.
 
- Public Member Functions inherited from cbdc::locking_shard::interface
 interface (std::pair< uint8_t, uint8_t > output_range)
 Constructor.
 
virtual ~interface ()=default
 
 interface ()=delete
 
 interface (const interface &)=delete
 
auto operator= (const interface &) -> interface &=delete
 
 interface (interface &&)=delete
 
auto operator= (interface &&) -> interface &=delete
 
virtual auto hash_in_shard_range (const hash_t &h) const -> bool
 Returns whether a given hash is within the shard's range.
 

Detailed Description

RPC client for the mutable interface to a locking shard raft cluster.

Definition at line 16 of file uhs/twophase/locking_shard/client.hpp.

Constructor & Destructor Documentation

◆ client() [1/4]

cbdc::locking_shard::rpc::client::client ( std::vector< network::endpoint_t > endpoints,
const std::pair< uint8_t, uint8_t > & output_range,
logging::log & logger )

Constructs a new locking shard client for issuing RPCs to a remote shard cluster.

The class is thread-safe on a per-dtx ID basis; only one thread should issue RPCs for a given dtx ID at a time.

Parameters
endpointsvector of shard node endpoints comprising the cluster
output_rangeinclusive range of UHS ID prefixes covered by the shard cluster
loggerlog instance for writing status messages

Definition at line 12 of file uhs/twophase/locking_shard/client.cpp.

◆ client() [2/4]

cbdc::locking_shard::rpc::client::client ( )
delete

◆ ~client()

cbdc::locking_shard::rpc::client::~client ( )
override

Definition at line 21 of file uhs/twophase/locking_shard/client.cpp.

References stop().

Here is the call graph for this function:

◆ client() [3/4]

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

◆ client() [4/4]

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

Member Function Documentation

◆ apply_outputs()

auto cbdc::locking_shard::rpc::client::apply_outputs ( std::vector< bool > && complete_txs,
const hash_t & dtx_id ) -> bool
overridevirtual

Issues an apply RPC to the remote shard and returns its response.

Parameters
complete_txsvector of flags to indicate which transactions in the distributed transaction should be finalized or rolled back
dtx_iddtx ID upon which to perform apply
Returns
true if the apply operation succeeded

Implements cbdc::locking_shard::interface.

Definition at line 39 of file uhs/twophase/locking_shard/client.cpp.

◆ discard_dtx()

auto cbdc::locking_shard::rpc::client::discard_dtx ( const hash_t & dtx_id) -> bool
overridevirtual

Issues a discard RPC to the remote shard and returns its response.

Parameters
dtx_iddtx ID to discard
Returns
true if the discard operation succeeded

Implements cbdc::locking_shard::interface.

Definition at line 46 of file uhs/twophase/locking_shard/client.cpp.

◆ init()

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

Initializes the RPC client.

Connects to the shard cluster and starts the response handler thread.

Returns
false if there is only one node in the cluster and connecting to it failed.

Definition at line 25 of file uhs/twophase/locking_shard/client.cpp.

Referenced by cbdc::locking_shard::rpc::status_client::init().

◆ lock_outputs()

auto cbdc::locking_shard::rpc::client::lock_outputs ( std::vector< tx > && txs,
const hash_t & dtx_id ) -> std::optional<std::vector<bool>>
overridevirtual

Issues a lock RPC to the remote shard and returns its response.

Parameters
txsvector of txs representing the input and output UHS IDs to lock for spending or creation
dtx_iddtx ID for this batch of transactions
Returns
if lock operation succeeds, a vector of flags indicating which transactions in the batch had their outputs belonging to the shard cluster locked

Implements cbdc::locking_shard::interface.

Definition at line 29 of file uhs/twophase/locking_shard/client.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ stop()

void cbdc::locking_shard::rpc::client::stop ( )
overridevirtual

Shuts down the client and unblocks any existing requests waiting for a response.

Implements cbdc::locking_shard::interface.

Definition at line 71 of file uhs/twophase/locking_shard/client.cpp.

Referenced by ~client().


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