6#ifndef OPENCBDC_TX_SRC_SENTINEL_2PC_CONTROLLER_H_
7#define OPENCBDC_TX_SRC_SENTINEL_2PC_CONTROLLER_H_
9#include "crypto/sha256.h"
38 std::shared_ptr<logging::log> logger);
70 static void result_handler(std::optional<bool> res,
78 std::unordered_set<size_t> requested);
83 std::unordered_set<size_t> requested);
88 uint32_t m_sentinel_id;
90 std::shared_ptr<logging::log> m_logger;
92 std::unique_ptr<cbdc::sentinel::rpc::async_server> m_rpc_server;
95 decltype(&secp256k1_context_destroy)>
96 m_secp{secp256k1_context_create(SECP256K1_CONTEXT_SIGN),
97 &secp256k1_context_destroy};
101 std::vector<std::unique_ptr<sentinel::rpc::client>>
102 m_sentinel_clients{};
104 std::random_device m_r{};
105 std::default_random_engine m_rand{m_r()};
106 std::uniform_int_distribution<size_t> m_dist{};
RPC client for a coordinator.
Interface for an asynchronous sentinel.
std::optional< cbdc::sentinel::validate_response > validate_result
Result of a validation operation.
std::function< void( std::optional< cbdc::sentinel::execute_response >)> execute_result_callback_type
Callback function for transaction execution result.
std::function< void(validate_result)> validate_result_callback_type
Callback function for providing a transaction validation result.
Manages a sentinel server for the two-phase commit architecture.
auto execute_transaction(transaction::full_tx tx, execute_result_callback_type result_callback) -> bool override
Statically validates a transaction, submits it the shard coordinator network, and returns the result ...
controller(const controller &)=delete
auto init() -> bool
Initializes the controller.
~controller() override=default
controller(controller &&)=delete
auto validate_transaction(transaction::full_tx tx, validate_result_callback_type result_callback) -> bool override
Statically validates a transaction and generates a sentinel attestation if the transaction is valid.
auto operator=(controller &&) -> controller &=delete
auto operator=(const controller &) -> controller &=delete
Tools for reading options from a configuration file and building application-specific parameter sets ...
struct secp256k1_context_struct secp256k1_context
std::array< unsigned char, pubkey_len > privkey_t
A private key of a public/private keypair.
Project-wide configuration options.
A condensed, hash-only transaction representation.