OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
status_client.cpp
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#include "status_client.hpp"
7
8#include "format.hpp"
9
12 std::vector<std::vector<network::endpoint_t>>
13 shard_read_only_endpoints,
14 std::vector<config::shard_range_t> shard_ranges,
15 std::chrono::milliseconds timeout)
16 : m_shard_ranges(std::move(shard_ranges)),
17 m_request_timeout(timeout) {
18 assert(m_shard_ranges.size() == shard_read_only_endpoints.size());
19 m_shard_clients.reserve(m_shard_ranges.size());
20 for(auto& cluster : shard_read_only_endpoints) {
21 m_shard_clients.emplace_back(
22 std::make_unique<
24 std::move(cluster)));
25 }
26 }
27
28 auto status_client::init() -> bool {
29 for(auto& client : m_shard_clients) {
30 if(!client->init()) {
31 return false;
32 }
33 }
34 return true;
35 }
36
38 -> std::optional<bool> {
39 return make_request<tx_status_request>(tx_id);
40 }
41
43 -> std::optional<bool> {
44 return make_request<uhs_status_request>(uhs_id);
45 }
46}
RPC client for the mutable interface to a locking shard raft cluster.
auto init() -> bool
Initializes the RPC client.
auto init() -> bool
Initializes the client by creating a TCP RPC client for each shard cluster.
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 c...
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.
Implements an RPC client over TCP sockets.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.