OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/twophase/sentinel_2pc/server.cpp
Go to the documentation of this file.
1// Copyright (c) 2021 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#include "server.hpp"
7
8namespace cbdc::sentinel::rpc {
10 async_interface* impl,
12 : m_impl(impl),
13 m_srv(std::move(srv)) {
14 m_srv->register_handler_callback(
15 [&](const request& req,
17 auto res = std::visit(
18 overloaded{[&](execute_request e_req) {
19 return m_impl->execute_transaction(
20 std::move(e_req),
21 callback);
22 },
23 [&](validate_request v_req) {
24 return m_impl->validate_transaction(
25 std::move(v_req),
26 callback);
27 }},
28 req);
29 return res;
30 });
31 }
32}
Generic asynchronous RPC server.
Interface for an asynchronous sentinel.
std::function< void(std::optional< cbdc::sentinel::response >)> result_callback_type
Callback function for a sentinel response.
virtual auto validate_transaction(transaction::full_tx tx, validate_result_callback_type result_callback) -> bool=0
Statically validate the given transaction and generate a sentinel attestation if the transaction is v...
virtual auto execute_transaction(transaction::full_tx tx, execute_result_callback_type result_callback) -> bool=0
Validate transaction on the sentinel, forward it to the coordinator network, and return the execution...
async_server(async_interface *impl, std::unique_ptr< cbdc::rpc::async_server< request, response > > srv)
Constructor.
std::variant< execute_request, validate_request > request
Sentinel RPC request type.
Variant handler template.
Request type for transaction validation and attestation.