OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
tx_error_messages.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
11#ifndef OPENCBDC_TX_SRC_WATCHTOWER_TX_ERROR_MESSAGES_H_
12#define OPENCBDC_TX_SRC_WATCHTOWER_TX_ERROR_MESSAGES_H_
13
18
19#include <memory>
20#include <string>
21#include <unordered_set>
22#include <variant>
23#include <vector>
24
25namespace cbdc::watchtower {
26 struct tx_error_sync;
27 class tx_error_inputs_dne;
28 struct tx_error_stxo_range;
29 struct tx_error_incomplete;
30 class tx_error_inputs_spent;
31
32 using tx_error_info = std::variant<tx_error_sync,
37
38 class tx_error;
39}
40
41namespace cbdc {
42 auto operator<<(cbdc::serializer& packet,
45 auto operator>>(cbdc::serializer& packet,
48 auto operator<<(cbdc::serializer& packet,
51 auto operator>>(cbdc::serializer& packet,
54 auto operator<<(cbdc::serializer& packet,
59}
60
61namespace cbdc::watchtower {
65 tx_error_sync() = default;
66
69 explicit tx_error_sync(cbdc::serializer& pkt);
70
71 auto operator==(const tx_error_sync& rhs) const -> bool;
72 };
73
77 public:
78 friend auto
82 friend auto
86
87 auto operator==(const tx_error_inputs_dne& rhs) const -> bool;
88
90
93 explicit tx_error_inputs_dne(std::vector<hash_t> input_uhs_ids);
94
98
101 [[nodiscard]] auto input_uhs_ids() const -> std::vector<hash_t>;
102
103 private:
104 std::vector<hash_t> m_input_uhs_ids;
105 };
106
111
115
116 auto operator==(const tx_error_stxo_range& rhs) const -> bool;
117 };
118
124
128
129 auto operator==(const tx_error_incomplete& rhs) const -> bool;
130 };
131
135 public:
136 friend auto
140 friend auto
144
145 auto operator==(const tx_error_inputs_spent& rhs) const -> bool;
146
148
151 explicit tx_error_inputs_spent(
152 std::unordered_set<hash_t, hashing::null> input_uhs_ids);
153
157
160 [[nodiscard]] auto input_uhs_ids() const
161 -> std::unordered_set<hash_t, hashing::null>;
162
163 private:
164 std::unordered_set<hash_t, hashing::null> m_input_uhs_ids;
165 };
166
168 class tx_error {
169 public:
176
177 auto operator==(const tx_error& rhs) const -> bool;
178
179 tx_error() = delete;
180
184 tx_error(const hash_t& tx_id, const tx_error_sync& err);
185
189 tx_error(const hash_t& tx_id, const tx_error_inputs_dne& err);
190
194 tx_error(const hash_t& tx_id, const tx_error_stxo_range& err);
195
199 tx_error(const hash_t& tx_id, const tx_error_incomplete& err);
200
204 tx_error(const hash_t& tx_id, const tx_error_inputs_spent& err);
205
208 explicit tx_error(cbdc::serializer& pkt);
209
212 [[nodiscard]] auto tx_id() const -> hash_t;
213
216 [[nodiscard]] auto info() const -> tx_error_info;
217
220 [[nodiscard]] auto to_string() const -> std::string;
221
222 private:
223 hash_t m_tx_id{};
224 std::shared_ptr<tx_error_info> m_info;
225 };
226}
227
228#endif // OPENCBDC_TX_SRC_WATCHTOWER_TX_ERROR_MESSAGES_H_
Interface for serializing objects into and out of raw bytes representations.
Indicates a shard that tried to process a given transaction could not locate one or more of the trans...
auto input_uhs_ids() const -> std::vector< hash_t >
Returns the UHS IDs of the inputs that caused this error.
auto operator==(const tx_error_inputs_dne &rhs) const -> bool
Indicates that the given transaction contains one or more inputs that have already been spent in othe...
Wrapper for transaction errors.
std::variant< tx_error_sync, tx_error_inputs_dne, tx_error_stxo_range, tx_error_incomplete, tx_error_inputs_spent > tx_error_info
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
auto operator>>(serializer &deser, parsec::agent::rpc::request &req) -> serializer &
auto operator<<(serializer &ser, const parsec::agent::rpc::request &req) -> serializer &
Indicates that the atomizer did not receive enough attestations for a particular transaction from sha...
Indicates that a shard did not attest to this transaction recently enough for the atomizer to check i...
Indicates a shard that tried to process a given transaction was out of sync with the atomizer,...
auto operator==(const tx_error_sync &rhs) const -> bool