OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/atomizer/atomizer/controller.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_ATOMIZER_CONTROLLER_H_
7#define OPENCBDC_TX_SRC_ATOMIZER_CONTROLLER_H_
8
9#include "atomizer_raft.hpp"
13
14#include <memory>
15
16namespace cbdc::atomizer {
18 class controller {
19 public:
20 controller() = delete;
21 controller(const controller&) = delete;
22 auto operator=(const controller&) -> controller& = delete;
24 auto operator=(controller&&) -> controller& = delete;
25
30 controller(uint32_t atomizer_id,
31 const config::options& opts,
32 std::shared_ptr<logging::log> log);
33
35
38 auto init() -> bool;
39
40 private:
41 uint32_t m_atomizer_id;
43 std::shared_ptr<logging::log> m_logger;
44
45 atomizer_raft m_raft_node;
46 std::atomic_bool m_running{true};
47
48 cbdc::network::connection_manager m_watchtower_network;
49 cbdc::network::connection_manager m_atomizer_network;
50
51 std::thread m_atomizer_server;
52 std::thread m_tx_notify_thread;
53 std::thread m_main_thread;
54
55 blocking_queue<tx_notify_request> m_notification_queue;
56 std::vector<std::thread> m_notification_threads;
57
58 auto server_handler(cbdc::network::message_t&& pkt)
59 -> std::optional<cbdc::buffer>;
60 void tx_notify_handler();
61 void main_handler();
62 void raft_result_handler(raft::result_type& r,
63 nuraft::ptr<std::exception>& err);
64 void err_return_handler(raft::result_type& r,
65 nuraft::ptr<std::exception>& err);
66 auto raft_callback(nuraft::cb_func::Type type,
67 nuraft::cb_func::Param* param)
68 -> nuraft::cb_func::ReturnCode;
69 void notification_consumer();
70 };
71}
72
73#endif // OPENCBDC_TX_SRC_ATOMIZER_CONTROLLER_H_
Manager for an atomizer raft node.
Wrapper for the atomizer raft executable implementation.
auto operator=(const controller &) -> controller &=delete
auto init() -> bool
Initializes the controller.
auto operator=(controller &&) -> controller &=delete
controller(const controller &)=delete
controller(controller &&)=delete
Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers.
Tools for reading options from a configuration file and building application-specific parameter sets ...
nuraft::cmd_result< nuraft::ptr< nuraft::buffer > > result_type
A NuRaft state machine execution result.
Definition node.hpp:18
Project-wide configuration options.
Definition config.hpp:132
Received message type.