15 -> std::pair<block, std::vector<cbdc::watchtower::tx_error>> {
22 std::vector<cbdc::watchtower::tx_error> errs;
23 for(
auto&& tx : m_txs[m_spent_cache_depth]) {
29 for(
size_t i = m_spent_cache_depth; i > 0; i--) {
30 m_spent[i] = std::move(m_spent[i - 1]);
31 m_txs[i] = std::move(m_txs[i - 1]);
36 static constexpr auto initial_spent_cache_size = 500000;
37 m_spent[0].reserve(initial_spent_cache_size);
46 std::unordered_set<uint32_t> attestations)
47 -> std::optional<cbdc::watchtower::tx_error> {
48 const auto height_offset = get_notification_offset(block_height);
50 auto offset_err = check_notification_offset(height_offset, tx);
58 auto it = m_txs[height_offset].find(tx);
59 if(it == m_txs[height_offset].end()) {
63 it = m_txs[height_offset]
64 .insert({std::move(tx), std::move(attestations)})
69 it->second.insert(attestations.begin(), attestations.end());
72 std::unordered_set<uint32_t> total_attestations;
73 size_t oldest_attestation{0};
74 std::map<size_t,
decltype(m_txs)::value_type::const_iterator> tx_its;
79 for(
size_t offset = 0; offset <= m_spent_cache_depth; offset++) {
80 const auto& tx_map = m_txs[offset];
84 const auto tx_it = tx_map.find(it->first);
85 if(tx_it != tx_map.end()) {
88 total_attestations.insert(tx_it->second.begin(),
93 oldest_attestation = offset;
98 tx_its.emplace(offset, tx_it);
102 const auto& txit = it->first;
104 auto cache_check_range = oldest_attestation;
108 if(total_attestations.size() == txit.m_inputs.size()) {
109 auto err_set = check_stxo_cache(txit, cache_check_range);
114 add_tx_to_stxo_cache(txit);
120 for(
const auto& pending_offset : tx_its) {
121 if(pending_offset.first == oldest_attestation) {
122 auto tx_ext = m_txs[pending_offset.first].extract(
123 pending_offset.second);
124 m_complete_txs.push_back(std::move(tx_ext.key()));
126 m_txs[pending_offset.first].erase(pending_offset.second);
136 -> std::optional<cbdc::watchtower::tx_error> {
137 const auto height_offset = get_notification_offset(oldest_attestation);
139 auto offset_err = check_notification_offset(height_offset, tx);
144 auto cache_check_range = height_offset;
146 auto err_set = check_stxo_cache(tx, cache_check_range);
151 add_tx_to_stxo_cache(tx);
153 m_complete_txs.push_back(std::move(tx));
221 auto atomizer::check_stxo_cache(
const transaction::compact_tx& tx,