OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
atomizer-raftd.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 "controller.hpp"
9
10#include <csignal>
11
12// LCOV_EXCL_START
13auto main(int argc, char** argv) -> int {
14 auto args = cbdc::config::get_args(argc, argv);
15 if(args.size() < 3) {
16 std::cerr << "Usage: " << args[0] << " <config file> <atomizer id>"
17 << std::endl;
18 return 0;
19 }
20
21 const auto atomizer_id = std::stoull(args[2]);
22
23 auto cfg_or_err = cbdc::config::load_options(args[1]);
24 if(std::holds_alternative<std::string>(cfg_or_err)) {
25 std::cerr << "Error loading config file: "
26 << std::get<std::string>(cfg_or_err) << std::endl;
27 return -1;
28 }
29 auto opts = std::get<cbdc::config::options>(cfg_or_err);
30
31 if(opts.m_atomizer_endpoints.size() <= atomizer_id) {
32 std::cerr << "Atomizer ID not in config file" << std::endl;
33 return -1;
34 }
35
36 auto logger = std::make_shared<cbdc::logging::log>(
37 opts.m_atomizer_loglevels[atomizer_id]);
38
39 auto ctl = cbdc::atomizer::controller{static_cast<uint32_t>(atomizer_id),
40 opts,
41 logger};
42
43 if(!ctl.init()) {
44 return -1;
45 }
46
47 static std::atomic_bool running{true};
48
49 std::signal(SIGINT, [](int /* signal */) {
50 running = false;
51 });
52
53 while(running) {
54 std::this_thread::sleep_for(std::chrono::seconds(1));
55 };
56
57 return 0;
58}
59// LCOV_EXCL_STOP
auto main(int argc, char **argv) -> int
Wrapper for the atomizer raft executable implementation.
Tools for reading options from a configuration file and building application-specific parameter sets ...
auto load_options(const std::string &config_file) -> std::variant< options, std::string >
Loads options from the given config file and check for invariants.
Definition config.cpp:668
auto get_args(int argc, char **argv) -> std::vector< std::string >
Converts c-args from an executable's main function into a vector of strings.
Definition config.cpp:751