OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::archiver::controller Class Reference

Wrapper for the archiver executable implementation. More...

#include <controller.hpp>

Public Member Functions

 controller ()=delete
 
 controller (const controller &)=delete
 
auto operator= (const controller &) -> controller &=delete
 
 controller (controller &&)=delete
 
auto operator= (controller &&) -> controller &=delete
 
 controller (uint32_t archiver_id, config::options opts, std::shared_ptr< logging::log > log, size_t max_samples)
 Constructor.
 
 ~controller ()
 
auto init () -> bool
 Initializes the controller with all its dependencies.
 
auto init_leveldb () -> bool
 Initializes the LevelDB database.
 
auto init_best_block () -> bool
 Initializes the best block value.
 
auto init_sample_collection () -> bool
 Initializes the sample collection.
 
auto init_atomizer_connection () -> bool
 Initializes the connection to the atomizer.
 
auto init_archiver_server () -> bool
 Initializes the archiver server.
 
auto best_block_height () const -> uint64_t
 Returns the archiver's best block height.
 
auto server_handler (cbdc::network::message_t &&pkt) -> std::optional< cbdc::buffer >
 Receives a request for an archived block and returns the block.
 
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 get_block (uint64_t height) -> std::optional< cbdc::atomizer::block >
 Queries the archiver database for the block at the specified height.
 
auto running () const -> bool
 Returns true if this archiver is receiving blocks from the atomizer.
 

Detailed Description

Wrapper for the archiver executable implementation.

Connects to the atomizer cluster to receive new blocks and listens for historical block requests from clients.

Definition at line 30 of file uhs/atomizer/archiver/controller.hpp.

Constructor & Destructor Documentation

◆ controller() [1/4]

cbdc::archiver::controller::controller ( )
delete

◆ controller() [2/4]

cbdc::archiver::controller::controller ( const controller & )
delete

◆ controller() [3/4]

cbdc::archiver::controller::controller ( controller && )
delete

◆ controller() [4/4]

cbdc::archiver::controller::controller ( uint32_t archiver_id,
config::options opts,
std::shared_ptr< logging::log > log,
size_t max_samples )

Constructor.

Parameters
archiver_idthe running ID of this archiver.
optsconfiguration options.
logpointer to shared logger.
max_samplesmaximum number of blocks to digest, for testing. 0=unlimited.

Definition at line 24 of file uhs/atomizer/archiver/controller.cpp.

◆ ~controller()

cbdc::archiver::controller::~controller ( )

Definition at line 33 of file uhs/atomizer/archiver/controller.cpp.

References cbdc::network::connection_manager::close().

Here is the call graph for this function:

Member Function Documentation

◆ atomizer_handler()

auto cbdc::archiver::controller::atomizer_handler ( cbdc::network::message_t && pkt) -> std::optional<cbdc::buffer>

Receives a serialized block from the atomizer and digests it.

Parameters
pktpacket containing the serialized block.
Returns
std::nullopt; no reply to atomizer necessary.
See also
digest_block
network::packet_handler_t

Definition at line 158 of file uhs/atomizer/archiver/controller.cpp.

References cbdc::from_buffer().

Here is the call graph for this function:

◆ best_block_height()

auto cbdc::archiver::controller::best_block_height ( ) const -> uint64_t
nodiscard

Returns the archiver's best block height.

Returns
best block height.

Definition at line 173 of file uhs/atomizer/archiver/controller.cpp.

◆ digest_block()

void cbdc::archiver::controller::digest_block ( const cbdc::atomizer::block & blk)

Adds a block to the archiver database.

Initializes the best block height field on its first call. If the controller's known best block height is not contiguous with the height of the provided block, recursively requests preceding blocks from the atomizer. Stores each received block in a deferred processing cache until receiving the next contiguous block, then digests each block in order.

Instructs connected atomizers to prune digested blocks.

Parameters
blkblock to digest.

Definition at line 177 of file uhs/atomizer/archiver/controller.cpp.

References digest_block(), cbdc::atomizer::block::m_height, cbdc::atomizer::block::m_transactions, and cbdc::make_buffer().

Referenced by digest_block().

Here is the call graph for this function:

◆ get_block()

auto cbdc::archiver::controller::get_block ( uint64_t height) -> std::optional<cbdc::atomizer::block>

Queries the archiver database for the block at the specified height.

Parameters
heightthe height of the block to retrieve.
Returns
the block at the specified height, or std::nullopt if the database does not contain a block at that height.

Definition at line 261 of file uhs/atomizer/archiver/controller.cpp.

References cbdc::buffer, and cbdc::from_buffer().

Here is the call graph for this function:

◆ init()

auto cbdc::archiver::controller::init ( ) -> bool

Initializes the controller with all its dependencies.

Returns
true if initialization succeeded.

Definition at line 48 of file uhs/atomizer/archiver/controller.cpp.

◆ init_archiver_server()

auto cbdc::archiver::controller::init_archiver_server ( ) -> bool

Initializes the archiver server.

Returns
true if initialization succeeded.

Definition at line 126 of file uhs/atomizer/archiver/controller.cpp.

◆ init_atomizer_connection()

auto cbdc::archiver::controller::init_atomizer_connection ( ) -> bool

Initializes the connection to the atomizer.

Returns
true if initialization succeeded.

Definition at line 112 of file uhs/atomizer/archiver/controller.cpp.

◆ init_best_block()

auto cbdc::archiver::controller::init_best_block ( ) -> bool

Initializes the best block value.

Returns
true if initialization succeeded.

Definition at line 86 of file uhs/atomizer/archiver/controller.cpp.

◆ init_leveldb()

auto cbdc::archiver::controller::init_leveldb ( ) -> bool

Initializes the LevelDB database.

Returns
true if initialization succeeded.

Definition at line 67 of file uhs/atomizer/archiver/controller.cpp.

◆ init_sample_collection()

auto cbdc::archiver::controller::init_sample_collection ( ) -> bool

Initializes the sample collection.

Returns
true if initialization succeeded.

Definition at line 102 of file uhs/atomizer/archiver/controller.cpp.

◆ operator=() [1/2]

auto cbdc::archiver::controller::operator= ( const controller & ) -> controller &=delete
delete

◆ operator=() [2/2]

auto cbdc::archiver::controller::operator= ( controller && ) -> controller &=delete
delete

◆ running()

auto cbdc::archiver::controller::running ( ) const -> bool
nodiscard

Returns true if this archiver is receiving blocks from the atomizer.

Will be true while the total number of digested blocks is less than max_samples.

Returns
false if the controller is finished digesting blocks.

Definition at line 143 of file uhs/atomizer/archiver/controller.cpp.

◆ server_handler()

auto cbdc::archiver::controller::server_handler ( cbdc::network::message_t && pkt) -> std::optional<cbdc::buffer>

Receives a request for an archived block and returns the block.

Parameters
pktpacket containing the request.
Returns
block or std::nullopt from get_block.
See also
network::packet_handler_t

Definition at line 147 of file uhs/atomizer/archiver/controller.cpp.

References cbdc::from_buffer(), and cbdc::make_buffer().

Here is the call graph for this function:

The documentation for this class was generated from the following files: