OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::atomizer::atomizer_raft Class Reference

Manager for an atomizer raft node. More...

#include <atomizer_raft.hpp>

Inheritance diagram for cbdc::atomizer::atomizer_raft:
Collaboration diagram for cbdc::atomizer::atomizer_raft:

Public Member Functions

 atomizer_raft (uint32_t atomizer_id, std::vector< network::endpoint_t > raft_endpoints, size_t stxo_cache_depth, std::shared_ptr< logging::log > logger, config::options opts, nuraft::cb_func::func_type raft_callback)
 Constructor.
 
auto make_request (const state_machine::request &r, const raft::callback_type &result_fn) -> bool
 Serialize and replicate the given request in the atomizer raft cluster.
 
auto get_sm () -> state_machine *
 Return a pointer to the state machine replicated by this raft node.
 
auto tx_notify_count () -> uint64_t
 Return the number of transaction notifications handled by the state machine.
 
void tx_notify (tx_notify_request &&notif)
 Add the given transaction notification to the set of pending notifications.
 
auto send_complete_txs (const raft::callback_type &result_fn) -> bool
 Replicate a transaction notification command in the state machine containing the current set of complete transactions.
 
- Public Member Functions inherited from cbdc::raft::node
 node ()=delete
 
 node (const node &)=delete
 
auto operator= (const node &) -> node &=delete
 
 node (node &&)=delete
 
auto operator= (node &&) -> node &=delete
 
 node (int node_id, std::vector< network::endpoint_t > raft_endpoints, const std::string &node_type, bool blocking, nuraft::ptr< nuraft::state_machine > sm, size_t asio_thread_pool_size, std::shared_ptr< logging::log > logger, nuraft::cb_func::func_type raft_cb)
 Constructor.
 
 ~node ()
 
auto init (const nuraft::raft_params &raft_params) -> bool
 Initializes the NuRaft instance with the given state machine and raft parameters.
 
auto is_leader () const -> bool
 Indicates whether this node is the current raft leader.
 
auto replicate (nuraft::ptr< nuraft::buffer > new_log, const callback_type &result_fn) const -> bool
 Replicates the given log entry in the cluster.
 
auto replicate_sync (const nuraft::ptr< nuraft::buffer > &new_log) const -> std::optional< nuraft::ptr< nuraft::buffer > >
 Replicates the provided log entry and returns the results from the state machine if the replication was successful.
 
auto last_log_idx () const -> uint64_t
 Returns the last replicated log index.
 
auto get_sm () const -> nuraft::state_machine *
 Returns a pointer to the state machine replicated by this raft node.
 
void stop ()
 Shut down the NuRaft instance.
 

Detailed Description

Manager for an atomizer raft node.

Handles initialization of an atomizer state machine and associated raft node. Replicates commands to the atomizer cluster and returns the state machine execution result via a callback function once available.

Definition at line 21 of file atomizer_raft.hpp.

Constructor & Destructor Documentation

◆ atomizer_raft()

cbdc::atomizer::atomizer_raft::atomizer_raft ( uint32_t atomizer_id,
std::vector< network::endpoint_t > raft_endpoints,
size_t stxo_cache_depth,
std::shared_ptr< logging::log > logger,
config::options opts,
nuraft::cb_func::func_type raft_callback )

Constructor.

Parameters
atomizer_idID of the raft node.
raft_endpointsnode endpoints for raft communications.
stxo_cache_depthnumber of blocks in the spent output cache.
loggerlog instance.
optsconfiguration options.
raft_callbackNuRaft callback for raft events.

Definition at line 15 of file atomizer_raft.cpp.

Member Function Documentation

◆ get_sm()

auto cbdc::atomizer::atomizer_raft::get_sm ( ) -> state_machine*
nodiscard

Return a pointer to the state machine replicated by this raft node.

Returns
state machine pointer.

Definition at line 35 of file atomizer_raft.cpp.

◆ make_request()

auto cbdc::atomizer::atomizer_raft::make_request ( const state_machine::request & r,
const raft::callback_type & result_fn ) -> bool

Serialize and replicate the given request in the atomizer raft cluster.

Return the response asynchronously via the given result function, if provided.

Parameters
rstate machine request to replicate.
result_fnfunction to call with the response, or nullptr to ignore the response.
Returns
true if the replication was initiated successfully.

Definition at line 42 of file atomizer_raft.cpp.

References cbdc::make_buffer().

Here is the call graph for this function:

◆ send_complete_txs()

auto cbdc::atomizer::atomizer_raft::send_complete_txs ( const raft::callback_type & result_fn) -> bool
nodiscard

Replicate a transaction notification command in the state machine containing the current set of complete transactions.

Parameters
result_fnfunction to call with the state machine execution result.
Returns
true if the command was accepted for replication.

Definition at line 122 of file atomizer_raft.cpp.

◆ tx_notify()

void cbdc::atomizer::atomizer_raft::tx_notify ( tx_notify_request && notif)

Add the given transaction notification to the set of pending notifications.

If the notification can be combined with previously received notifications to create an aggregate notification with a full set of input attestations, create an aggregate notification and add it to a list of complete transactions.

Parameters
notiftransaction notification.

Definition at line 55 of file atomizer_raft.cpp.

References cbdc::transaction::validation::check_attestations(), cbdc::config::options::m_attestation_threshold, cbdc::config::options::m_sentinel_public_keys, and cbdc::to_string().

Here is the call graph for this function:

◆ tx_notify_count()

auto cbdc::atomizer::atomizer_raft::tx_notify_count ( ) -> uint64_t
nodiscard

Return the number of transaction notifications handled by the state machine.

Returns
number of transaction notifications.

Definition at line 51 of file atomizer_raft.cpp.


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