OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
twophase_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_CLIENT_TWOPHASE_CLIENT_H_
7#define OPENCBDC_TX_SRC_CLIENT_TWOPHASE_CLIENT_H_
8
9#include "client.hpp"
12
13namespace cbdc {
15 class twophase_client : public client {
16 public:
25 const std::shared_ptr<logging::log>& logger,
26 const std::string& wallet_file,
27 const std::string& client_file);
28
29 ~twophase_client() override = default;
30
31 twophase_client() = delete;
33 auto operator=(const twophase_client&) -> twophase_client& = delete;
36
44 auto sync() -> bool override;
45
53 auto check_tx_id(const hash_t& tx_id) -> std::optional<bool>;
54
61 auto check_unspent(const hash_t& uhs_id) -> std::optional<bool>;
62
63 protected:
71 auto init_derived() -> bool override;
72
76 auto send_mint_tx(const transaction::full_tx& mint_tx)
77 -> bool override;
78
79 private:
80 coordinator::rpc::client m_coordinator_client;
81 cbdc::locking_shard::rpc::status_client m_shard_status_client;
82 std::shared_ptr<logging::log> m_logger;
84
85 std::unique_ptr<secp256k1_context,
86 decltype(&secp256k1_context_destroy)>
87 m_secp{secp256k1_context_create(SECP256K1_CONTEXT_SIGN),
88 &secp256k1_context_destroy};
89
90 static constexpr auto m_client_timeout
91 = std::chrono::milliseconds(5000);
92 };
93}
94
95#endif
External client for sending new transactions to the system.
Client for interacting with the read-only port on 2PC shards.
Client for interacting with the 2PC architecture.
auto check_unspent(const hash_t &uhs_id) -> std::optional< bool >
Checks the shard network for the status of a specific UHS ID.
twophase_client(twophase_client &&)=delete
auto sync() -> bool override
Update the client with the latest state from the shard network.
auto send_mint_tx(const transaction::full_tx &mint_tx) -> bool override
Sends the given mint transaction directly to a coordinator cluster.
auto operator=(twophase_client &&) -> twophase_client &=delete
auto check_tx_id(const hash_t &tx_id) -> std::optional< bool >
Checks the shard network for the status of a specific transaction.
auto init_derived() -> bool override
Initializes the 2PC architecture client.
~twophase_client() override=default
auto operator=(const twophase_client &) -> twophase_client &=delete
twophase_client(const twophase_client &)=delete
struct secp256k1_context_struct secp256k1_context
Definition keys.hpp:14
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
Project-wide configuration options.
Definition config.hpp:132
A complete transaction.