6#ifndef OPENCBDC_TX_SRC_ARCHIVER_CONTROLLER_H_
7#define OPENCBDC_TX_SRC_ARCHIVER_CONTROLLER_H_
14#include <leveldb/db.h>
45 std::shared_ptr<logging::log> log,
112 -> std::optional<
cbdc::atomizer::block>;
120 [[nodiscard]] auto
running() const ->
bool;
123 uint32_t m_archiver_id;
124 cbdc::config::options m_opts;
125 std::shared_ptr<logging::log> m_logger;
127 std::unique_ptr<leveldb::DB> m_db;
128 uint64_t m_best_height{0};
132 std::map<uint64_t, cbdc::atomizer::block> m_deferred;
133 std::ofstream m_tp_sample_file;
134 std::chrono::high_resolution_clock::time_point m_last_block_time;
135 size_t m_max_samples{};
141 bool m_sample_collection_active{
false};
143 std::thread m_atomizer_handler_thread;
144 std::thread m_archiver_server;
146 std::atomic_bool m_running{
true};
148 const std::string m_bestblock_key =
"bestblock";
149 static constexpr const leveldb::ReadOptions m_read_options{};
150 static const leveldbWriteOptions m_write_options;
152 void request_block(uint64_t height);
153 void request_prune(uint64_t height);
Wrapper for the archiver executable implementation.
auto get_block(uint64_t height) -> std::optional< cbdc::atomizer::block >
Queries the archiver database for the block at the specified height.
auto init() -> bool
Initializes the controller with all its dependencies.
auto running() const -> bool
Returns true if this archiver is receiving blocks from the atomizer.
auto init_sample_collection() -> bool
Initializes the sample collection.
auto atomizer_handler(cbdc::network::message_t &&pkt) -> std::optional< cbdc::buffer >
Receives a serialized block from the atomizer and digests it.
void digest_block(const cbdc::atomizer::block &blk)
Adds a block to the archiver database.
auto init_leveldb() -> bool
Initializes the LevelDB database.
auto best_block_height() const -> uint64_t
Returns the archiver's best block height.
controller(controller &&)=delete
auto operator=(controller &&) -> controller &=delete
auto init_archiver_server() -> bool
Initializes the archiver server.
auto server_handler(cbdc::network::message_t &&pkt) -> std::optional< cbdc::buffer >
Receives a request for an archived block and returns the block.
controller(const controller &)=delete
auto operator=(const controller &) -> controller &=delete
auto init_best_block() -> bool
Initializes the best block value.
auto init_atomizer_connection() -> bool
Initializes the connection to the atomizer.
Buffer to store and retrieve byte data.
Manages a group of peer s.
Tools for reading options from a configuration file and building application-specific parameter sets ...
Wrapper for leveldb::WriteOptions to provide a constructor to set base class member "sync".
leveldbWriteOptions(bool do_sync)
Project-wide configuration options.