OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/atomizer/watchtower/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
10#ifndef OPENCBDC_TX_SRC_WATCHTOWER_CLIENT_H_
11#define OPENCBDC_TX_SRC_WATCHTOWER_CLIENT_H_
12
19
20namespace cbdc::watchtower {
23 public:
24 blocking_client() = delete;
28
31 auto init() -> bool;
32
34
36 auto operator=(const blocking_client&) -> blocking_client& = delete;
39
44 -> std::shared_ptr<best_block_height_response>;
45
51 -> std::shared_ptr<status_request_check_success>;
52
53 private:
56 std::thread m_client_thread;
58 };
59
62 public:
63 async_client() = delete;
67
69
70 async_client(const async_client&) = delete;
71 auto operator=(const async_client&) -> async_client& = delete;
73 auto operator=(async_client&&) -> async_client& = delete;
74
77 auto init() -> bool;
78
81
84
85 using status_update_response_handler_t = std::function<void(
86 std::shared_ptr<status_request_check_success>&&)>;
87
93
94 using best_block_height_handler_t = std::function<void(
95 std::shared_ptr<best_block_height_response>&&)>;
96
100 void
102
103 private:
106 std::thread m_client_thread;
107 std::thread m_handler_thread;
108 bool m_handler_running{false};
111 best_block_height_handler_t m_bbh_handler;
112 };
113}
114
115#endif // OPENCBDC_TX_SRC_WATCHTOWER_CLIENT_H_
Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers.
Client to asynchronously request information from the watchtower.
auto init() -> bool
Attempts to connect to the watchtower.
void set_block_height_handler(const best_block_height_handler_t &handler)
Sets or replaces the handler for asynchronously delivered StatusUpdateResponses.
void request_status_update(const status_update_request &req)
Sends a StatusUpdateRequest to the Watchtower.
async_client(async_client &&)=delete
void set_status_update_handler(const status_update_response_handler_t &handler)
Sets or replaces the handler for asynchronously delivered StatusUpdateResponses.
auto operator=(const async_client &) -> async_client &=delete
async_client(const async_client &)=delete
void request_best_block_height()
Sends a request_best_block_height to the Watchtower.
auto operator=(async_client &&) -> async_client &=delete
std::function< void( std::shared_ptr< best_block_height_response > &&)> best_block_height_handler_t
std::function< void( std::shared_ptr< status_request_check_success > &&)> status_update_response_handler_t
Client to synchronously request information from the watchtower.
auto operator=(blocking_client &&) -> blocking_client &=delete
blocking_client(blocking_client &&)=delete
auto init() -> bool
Attempts to connect to the watchtower.
auto request_status_update(const status_update_request &req) -> std::shared_ptr< status_request_check_success >
Sends a StatusUpdateRequest to the Watchtower.
blocking_client(const blocking_client &)=delete
auto operator=(const blocking_client &) -> blocking_client &=delete
auto request_best_block_height() -> std::shared_ptr< best_block_height_response >
Sends a request_best_block_height to the Watchtower.
Network request to interact with the Watchtower's status update service.
Tools for reading options from a configuration file and building application-specific parameter sets ...
std::pair< ip_address, port_number_t > endpoint_t
[host name, port number].
Definition socket.hpp:19
Watchtower module to process and cache block history.
Messages clients can use to communicate with the Watchtower.