OpenCBDC Transaction Processor
|
Stores a set of blocks in memory and maintains an index of the UHS IDs contained therein. More...
#include <block_cache.hpp>
Public Member Functions | |
block_cache ()=delete | |
block_cache (size_t k) | |
Constructor. | |
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 size. | |
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 | 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. | |
auto | best_block_height () const -> uint64_t |
Returns the block height of the highest observed block. | |
Stores a set of blocks in memory and maintains an index of the UHS IDs contained therein.
Definition at line 30 of file block_cache.hpp.
|
delete |
|
explicit |
Constructor.
k | number of blocks to store in memory. 0 -> no limit. |
Definition at line 9 of file block_cache.cpp.
auto cbdc::watchtower::block_cache::best_block_height | ( | ) | const -> uint64_t |
Returns the block height of the highest observed block.
Definition at line 64 of file block_cache.cpp.
auto cbdc::watchtower::block_cache::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.
uhs_id | UHS ID to check. |
Definition at line 56 of file block_cache.cpp.
Referenced by cbdc::watchtower::watchtower::add_errors().
auto cbdc::watchtower::block_cache::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.
uhs_id | UHS ID to check. |
Definition at line 47 of file block_cache.cpp.
Referenced by cbdc::watchtower::watchtower::add_errors().
void cbdc::watchtower::block_cache::push_block | ( | cbdc::atomizer::block && | blk | ) |
Moves a block into the block cache, evicting the oldest block if the cache has reached its maximum size.
blk | the block to move into the cache. |
Definition at line 16 of file block_cache.cpp.
Referenced by cbdc::watchtower::watchtower::add_block().