OpenCBDC Transaction Processor
|
Atomizer implementation. More...
#include <atomizer.hpp>
Public Member Functions | |
atomizer (uint64_t best_height, size_t stxo_cache_depth) | |
Constructor. | |
~atomizer ()=default | |
atomizer ()=delete | |
atomizer (const atomizer &)=delete | |
auto | operator= (const atomizer &) -> atomizer &=delete |
atomizer (atomizer &&)=delete | |
auto | operator= (atomizer &&) -> atomizer &=delete |
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 specified block height. | |
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 inclusion in the next block. | |
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 transmission to subscribers. | |
auto | pending_transactions () const -> size_t |
Returns the number of complete transactions waiting to be included in the next block. | |
auto | height () const -> uint64_t |
Returns the height of the most recent block. | |
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 | operator== (const atomizer &other) const -> bool |
Atomizer implementation.
Aggregates transaction notifications and input attestations. Accepts transactions with a full set of attestations, and provides block construction functionality. Keeps track of recently spent UHS IDs and the block height at which they were spent to enable input attestations that are not valid as of the most recent block height to still be used. This works because inputs covered by attestations with a block height lower than the most recent block will be in the spent cache if they are unspendable. Otherwise, the atomizer can be certain the inputs not have been spent.
Definition at line 32 of file atomizer.hpp.
cbdc::atomizer::atomizer::atomizer | ( | uint64_t | best_height, |
size_t | stxo_cache_depth ) |
Constructor.
best_height | starting block height. |
stxo_cache_depth | maximum number of recent blocks over which to maintain the spent UHS IDs cache. |
Definition at line 166 of file atomizer.cpp.
|
default |
|
delete |
|
delete |
|
delete |
void cbdc::atomizer::atomizer::deserialize | ( | cbdc::serializer & | buf | ) |
Replaces the state of this atomizer instance with the provided serialized state data.
buf | serialized atomizer state produced with serialize. |
Definition at line 184 of file atomizer.cpp.
|
nodiscard |
Returns the height of the most recent block.
Definition at line 162 of file atomizer.cpp.
|
nodiscard |
Attempts to add the specified shard attestations for a specified transaction at or later than the specified block height.
Creates a new pending transaction if necessary. If the provided transaction is already pending, merges the new attestations. Returns an error to forward to the watchtower if:
block_height | the block height at which the shard provided the attestations. |
tx | the complete transaction. |
attestations | a set of the input indices to which the shard attested the validity. |
Definition at line 44 of file atomizer.cpp.
|
nodiscard |
Attempts to add the given compact transaction to the list of complete transactions pending for inclusion in the next block.
If the block height of the oldest attestation in the transaction precedes the height of the earliest block in the spent UHS ID cache, discards the transaction and returns a watchtower error. If the compact transaction attempts to spend a UHS ID matching one in the spent UHS ID cache, discards the compact TX and returns a watchtower error.
oldest_attestation | block height of the oldest shard attestation in the notification. |
tx | compact transaction to insert in the next block. |
Definition at line 134 of file atomizer.cpp.
|
nodiscard |
Adds the current set of complete transactions to a new block and returns it for storage and transmission to subscribers.
Rotates the STXO cache, evicting the oldest set of transactions. Generates and returns a set of errors containing an error for each incomplete transaction in the set of evicted transactions, or an empty vector if there are no such errors.
Definition at line 14 of file atomizer.cpp.
References cbdc::atomizer::block::m_height, and cbdc::atomizer::block::m_transactions.
auto cbdc::atomizer::atomizer::operator== | ( | const atomizer & | other | ) | const -> bool |
Definition at line 195 of file atomizer.cpp.
|
nodiscard |
Returns the number of complete transactions waiting to be included in the next block.
Definition at line 158 of file atomizer.cpp.
|
nodiscard |
Serializes the internal state of the atomizer into a buffer.
Definition at line 174 of file atomizer.cpp.
References cbdc::buffer.