OpenCBDC Transaction Processor
|
Manager for an atomizer raft node. More...
#include <atomizer_raft.hpp>
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 &¬if) |
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. | |
![]() | |
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. | |
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.
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.
atomizer_id | ID of the raft node. |
raft_endpoints | node endpoints for raft communications. |
stxo_cache_depth | number of blocks in the spent output cache. |
logger | log instance. |
opts | configuration options. |
raft_callback | NuRaft callback for raft events. |
Definition at line 15 of file atomizer_raft.cpp.
|
nodiscard |
Return a pointer to the state machine replicated by this raft node.
Definition at line 35 of file atomizer_raft.cpp.
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.
r | state machine request to replicate. |
result_fn | function to call with the response, or nullptr to ignore the response. |
Definition at line 42 of file atomizer_raft.cpp.
References cbdc::make_buffer().
|
nodiscard |
Replicate a transaction notification command in the state machine containing the current set of complete transactions.
result_fn | function to call with the state machine execution result. |
Definition at line 122 of file atomizer_raft.cpp.
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.
notif | transaction 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().
|
nodiscard |
Return the number of transaction notifications handled by the state machine.
Definition at line 51 of file atomizer_raft.cpp.