6#ifndef OPENCBDC_TX_SRC_ATOMIZER_ATOMIZER_H_
7#define OPENCBDC_TX_SRC_ATOMIZER_ATOMIZER_H_
16#include <unordered_map>
17#include <unordered_set>
38 atomizer(uint64_t best_height,
size_t stxo_cache_depth);
62 [[nodiscard]]
auto insert(uint64_t block_height,
64 std::unordered_set<uint32_t> attestations)
65 -> std::optional<watchtower::tx_error>;
84 -> std::optional<watchtower::tx_error>;
96 std::vector<watchtower::tx_error>>;
105 [[nodiscard]] auto
height() const -> uint64_t;
116 auto operator==(const
atomizer& other) const ->
bool;
119 std::vector<std::unordered_map<transaction::compact_tx,
120 std::unordered_set<uint32_t>,
121 transaction::compact_tx_hasher>>
126 std::vector<transaction::compact_tx> m_complete_txs;
128 std::vector<std::unordered_set<
hash_t, hashing::null>> m_spent;
130 uint64_t m_best_height{};
131 size_t m_spent_cache_depth;
133 [[nodiscard]]
auto get_notification_offset(uint64_t block_height)
const
137 check_notification_offset(uint64_t height_offset,
139 -> std::optional<watchtower::tx_error>;
142 uint64_t cache_check_range)
const
143 -> std::optional<watchtower::tx_error>;
atomizer(atomizer &&)=delete
auto operator=(const atomizer &) -> atomizer &=delete
atomizer(const atomizer &)=delete
auto pending_transactions() const -> size_t
Returns the number of complete transactions waiting to be included in the next block.
auto insert(uint64_t block_height, transaction::compact_tx tx, std::unordered_set< uint32_t > attestations) -> std::optional< watchtower::tx_error >
Attempts to add the specified shard attestations for a specified transaction at or later than the spe...
auto height() const -> uint64_t
Returns the height of the most recent block.
auto operator=(atomizer &&) -> atomizer &=delete
auto serialize() -> buffer
Serializes the internal state of the atomizer into a buffer.
void deserialize(serializer &buf)
Replaces the state of this atomizer instance with the provided serialized state data.
auto make_block() -> std::pair< cbdc::atomizer::block, std::vector< watchtower::tx_error > >
Adds the current set of complete transactions to a new block and returns it for storage and transmiss...
auto insert_complete(uint64_t oldest_attestation, transaction::compact_tx &&tx) -> std::optional< watchtower::tx_error >
Attempts to add the given compact transaction to the list of complete transactions pending for inclus...
Buffer to store and retrieve byte data.
Interface for serializing objects into and out of raw bytes representations.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
Batch of compact transactions settled by the atomizer.
A condensed, hash-only transaction representation.
Messages atomizers and shards can use to transmit errors to the watchtower, and which the watchtower ...