OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/twophase/locking_shard/client.hpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_LOCKING_SHARD_CLIENT_H_
7#define OPENCBDC_TX_SRC_LOCKING_SHARD_CLIENT_H_
8
9#include "interface.hpp"
10#include "messages.hpp"
13
16 class client final : public interface {
17 public:
26 client(std::vector<network::endpoint_t> endpoints,
27 const std::pair<uint8_t, uint8_t>& output_range,
28 logging::log& logger);
29
30 client() = delete;
31 ~client() override;
32 client(const client&) = delete;
33 auto operator=(const client&) -> client& = delete;
34 client(client&&) = delete;
35 auto operator=(client&&) -> client& = delete;
36
41 auto init() -> bool;
42
50 auto lock_outputs(std::vector<tx>&& txs, const hash_t& dtx_id)
51 -> std::optional<std::vector<bool>> override;
52
59 auto apply_outputs(std::vector<bool>&& complete_txs,
60 const hash_t& dtx_id) -> bool override;
61
65 auto discard_dtx(const hash_t& dtx_id) -> bool override;
66
69 void stop() override;
70
71 private:
72 auto send_request(const request& req) -> std::optional<response>;
73
74 std::atomic_bool m_running{true};
75
76 std::unique_ptr<cbdc::rpc::tcp_client<request, response>> m_client;
77
78 logging::log& m_log;
79 };
80}
81
82#endif // OPENCBDC_TX_SRC_LOCKING_SHARD_CLIENT_H_
RPC client for the mutable interface to a locking shard raft cluster.
void stop() override
Shuts down the client and unblocks any existing requests waiting for a response.
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 operator=(client &&) -> client &=delete
client(const client &)=delete
auto init() -> bool
Initializes the RPC client.
auto discard_dtx(const hash_t &dtx_id) -> bool override
Issues a discard 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 operator=(const client &) -> client &=delete
Generalized logging class.
Definition logging.hpp:51
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.