OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/twophase/locking_shard/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_LOCKING_SHARD_LOCKING_SHARD_INTERFACE_H_
7#define OPENCBDC_TX_SRC_LOCKING_SHARD_LOCKING_SHARD_INTERFACE_H_
8
10#include "util/common/hash.hpp"
11
12#include <optional>
13#include <variant>
14#include <vector>
15
16namespace cbdc::locking_shard {
18 struct tx {
21
22 auto operator==(const tx& rhs) const -> bool;
23 };
24
30 class interface {
31 public:
35 explicit interface(std::pair<uint8_t, uint8_t> output_range);
36 virtual ~interface() = default;
37 interface() = delete;
38 interface(const interface&) = delete;
39 auto operator=(const interface&) -> interface& = delete;
40 interface(interface&&) = delete;
41 auto operator=(interface&&) -> interface& = delete;
42
53 virtual auto lock_outputs(std::vector<tx>&& txs, const hash_t& dtx_id)
54 -> std::optional<std::vector<bool>> = 0;
55
65 virtual auto apply_outputs(std::vector<bool>&& complete_txs,
66 const hash_t& dtx_id) -> bool
67 = 0;
68
72 [[nodiscard]] virtual auto hash_in_shard_range(const hash_t& h) const
73 -> bool;
74
80 virtual auto discard_dtx(const hash_t& dtx_id) -> bool = 0;
81
84 virtual void stop() = 0;
85
86 private:
87 std::pair<uint8_t, uint8_t> m_output_range;
88 };
89}
90
91#endif // OPENCBDC_TX_SRC_LOCKING_SHARD_LOCKING_SHARD_INTERFACE_H_
virtual void stop()=0
Stops the locking shard implementation from processing further commands and unblocks any pending comm...
auto operator=(interface &&) -> interface &=delete
virtual auto lock_outputs(std::vector< tx > &&txs, const hash_t &dtx_id) -> std::optional< std::vector< bool > >=0
Attempts to lock the input hashes for the given vector of transactions.
interface(interface &&)=delete
virtual auto apply_outputs(std::vector< bool > &&complete_txs, const hash_t &dtx_id) -> bool=0
Completes a previous lock operation by deleting input hashes and creating output hashes,...
auto operator=(const interface &) -> interface &=delete
virtual ~interface()=default
interface(const interface &)=delete
virtual auto discard_dtx(const hash_t &dtx_id) -> bool=0
Discards any cached information about a given distributed transaction.
virtual auto hash_in_shard_range(const hash_t &h) const -> bool
Returns whether a given hash is within the shard's range.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
Transaction type processed by locking shards.
transaction::compact_tx m_tx
Compact TX.
auto operator==(const tx &rhs) const -> bool
A condensed, hash-only transaction representation.