10#ifndef OPENCBDC_TX_SRC_WATCHTOWER_BLOCK_CACHE_H_
11#define OPENCBDC_TX_SRC_WATCHTOWER_BLOCK_CACHE_H_
16#include <forward_list>
21#include <shared_mutex>
22#include <unordered_map>
48 -> std::optional<block_cache_result>;
55 -> std::optional<block_cache_result>;
63 std::queue<
cbdc::atomizer::block> m_blks;
64 uint64_t m_best_blk_height{0};
Stores a set of blocks in memory and maintains an index of the UHS IDs contained therein.
void push_block(cbdc::atomizer::block &&blk)
Moves a block into the block cache, evicting the oldest block if the cache has reached its maximum si...
auto check_unspent(const hash_t &uhs_id) const -> std::optional< block_cache_result >
Checks to see if the given UHS ID is spendable according to the blocks in the cache.
auto best_block_height() const -> uint64_t
Returns the block height of the highest observed block.
auto check_spent(const hash_t &uhs_id) const -> std::optional< block_cache_result >
Checks to see if the given UHS ID has been spent according to the blocks in the cache.
std::pair< size_t, hash_t > block_cache_result
With respect to a particular UHS ID, block height + ID of containing transaction.
std::array< unsigned char, cbdc::hash_size > hash_t
SHA256 hash container.
Batch of compact transactions settled by the atomizer.
SipHash function to generate STL data structure hash keys for system IDs.