OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/sentinel/interface.hpp
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#ifndef OPENCBDC_TX_SRC_SENTINEL_INTERFACE_H_
7#define OPENCBDC_TX_SRC_SENTINEL_INTERFACE_H_
8
10#include "util/common/hash.hpp"
12
13#include <optional>
14#include <string>
15
16namespace cbdc::sentinel {
18 enum class tx_status {
21 pending,
32 };
33
42
46 auto to_string(tx_status status) -> std::string;
47
50
56 std::optional<transaction::validation::tx_error> m_tx_error;
57
58 auto operator==(const execute_response& rhs) const -> bool;
59 };
60
67
70 using request = std::variant<execute_request, validate_request>;
73 using response = std::variant<execute_response, validate_response>;
74
76 class interface {
77 public:
78 virtual ~interface() = default;
79
80 interface() = default;
81 interface(const interface&) = delete;
82 auto operator=(const interface&) -> interface& = delete;
83 interface(interface&&) = delete;
84 auto operator=(interface&&) -> interface& = delete;
85
93 -> std::optional<execute_response> = 0;
94
101 -> std::optional<validate_response> = 0;
102 };
103}
104
105#endif
Interface for a sentinel.
virtual auto execute_transaction(transaction::full_tx tx) -> std::optional< execute_response >=0
Validate transaction on the sentinel, and forward it to the coordinator or shards depending on the im...
auto operator=(interface &&) -> interface &=delete
interface(const interface &)=delete
virtual auto validate_transaction(transaction::full_tx tx) -> std::optional< validate_response >=0
Validate transaction and generate a sentinel attestation if the transaction is valid.
virtual ~interface()=default
interface(interface &&)=delete
auto operator=(const interface &) -> interface &=delete
std::pair< uint8_t, uint8_t > shard_range_t
[start, end] inclusive.
Definition config.hpp:129
size_t peer_id_t
Peer IDs within a connection_manager.
transaction::sentinel_attestation validate_response
Response type from transaction validation, a sentinel attestation on the given transaction.
auto to_string(tx_status status) -> std::string
Return a human-readable string describing a tx_status.
std::variant< execute_response, validate_response > response
Sentinel RPC response type.
tx_status
Status of the transaction following sentinel processing.
@ static_invalid
Statically invalid. Must be fixed and resubmitted.
@ state_invalid
Statically valid, but rejected by the shards for trying to spend inputs either that do not exist or t...
@ pending
Statically valid, and the sentinel has submitted the transaction to the network for processing.
@ confirmed
Executed to completion.
std::variant< execute_request, validate_request > request
Sentinel RPC request type.
std::pair< pubkey_t, signature_t > sentinel_attestation
Sentinel attestation type.
cbdc::sentinel::tx_status m_tx_status
Transaction execution status.
auto operator==(const execute_response &rhs) const -> bool
std::optional< transaction::validation::tx_error > m_tx_error
Transaction validation error if static validation failed.
Sentinel-specific representation of shard network information.
cbdc::network::peer_id_t m_peer_id
Network ID of the peer corresponding to this shard generated by a call to cbdc::network::network::con...
config::shard_range_t m_range
UHS ID range.
Request type for transaction validation and attestation.
A complete transaction.