OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
server_interface.hpp
Go to the documentation of this file.
1// Copyright (c) 2022 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_PARSEC_AGENT_SERVER_INTERFACE_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_SERVER_INTERFACE_H_
8
9#include "interface.hpp"
10#include "messages.hpp"
11#include "parsec/agent/impl.hpp"
16
17#include <atomic>
18#include <memory>
19#include <secp256k1.h>
20#include <thread>
21
26 public:
32 server_interface(std::shared_ptr<broker::interface> broker,
33 std::shared_ptr<logging::log> log,
34 const cbdc::parsec::config& cfg);
35
37 virtual ~server_interface();
38
40 virtual auto init() -> bool = 0;
41
43 auto operator=(const server_interface&) -> server_interface& = delete;
46
47 private:
48 friend class server;
49 friend class http_server;
50
51 std::shared_ptr<broker::interface> m_broker;
52 std::shared_ptr<logging::log> m_log;
53 const cbdc::parsec::config& m_cfg;
54
55 mutable std::mutex m_agents_mut;
56 std::atomic<size_t> m_next_id{};
57 std::unordered_map<size_t, std::shared_ptr<agent::impl>> m_agents;
58
59 blocking_queue<size_t> m_cleanup_queue;
60 std::thread m_cleanup_thread;
61
63 std::thread m_retry_thread;
64
65 std::shared_ptr<thread_pool> m_threads{
66 std::make_shared<thread_pool>()};
67
68 std::shared_ptr<secp256k1_context> m_secp{
69 secp256k1_context_create(SECP256K1_CONTEXT_SIGN
70 | SECP256K1_CONTEXT_VERIFY),
71 &secp256k1_context_destroy};
72 };
73}
74
75#endif
Thread-safe producer-consumer FIFO queue supporting multiple concurrent producers and consumers.
auto operator=(const server_interface &) -> server_interface &=delete
server_interface(std::shared_ptr< broker::interface > broker, std::shared_ptr< logging::log > log, const cbdc::parsec::config &cfg)
Constructor.
server_interface(const server_interface &)=delete
virtual auto init() -> bool=0
Initializes the server, starts processing requests.
virtual ~server_interface()
Stops retrying additional transactions and cleans up the runners.
auto operator=(server_interface &&) -> server_interface &=delete
server_interface(server_interface &&)=delete
RPC server for an agent running a Lua exector.
Configuration parameters for a phase two system.