diff --git a/include/bitcoin/database/error.hpp b/include/bitcoin/database/error.hpp index d0684d75..2a03d9b2 100644 --- a/include/bitcoin/database/error.hpp +++ b/include/bitcoin/database/error.hpp @@ -111,8 +111,8 @@ enum error_t : uint8_t tx_point_put, tx_spend_set, tx_output_put, - tx_tx_set, tx_puts_put, + tx_tx_set, tx_spend_commit, tx_address_put, tx_tx_commit, @@ -121,10 +121,10 @@ enum error_t : uint8_t header_put, /// txs archive - txs_empty, txs_header, - txs_txs_put, - txs_confirm + txs_empty, + txs_confirm, + txs_txs_put }; // No current need for error_code equivalence mapping. diff --git a/include/bitcoin/database/impl/primitives/hashmap.ipp b/include/bitcoin/database/impl/primitives/hashmap.ipp index 4aa1f11e..d7a73e21 100644 --- a/include/bitcoin/database/impl/primitives/hashmap.ipp +++ b/include/bitcoin/database/impl/primitives/hashmap.ipp @@ -376,8 +376,8 @@ Link CLASS::first(const memory_ptr& ptr, Link link, const Key& key) NOEXCEPT return {}; // element key matches (found) - const auto key_ptr = std::next(offset, Link::size); - if (is_zero(std::memcmp(key.data(), key_ptr, array_count))) + if (is_zero(std::memcmp(key.data(), std::next(offset, Link::size), + array_count))) return link; // set next element link (loop) diff --git a/include/bitcoin/database/impl/query/archive.ipp b/include/bitcoin/database/impl/query/archive.ipp index 52cb706a..69344bf7 100644 --- a/include/bitcoin/database/impl/query/archive.ipp +++ b/include/bitcoin/database/impl/query/archive.ipp @@ -302,13 +302,13 @@ TEMPLATE bool CLASS::get_tx_position(size_t& out, const tx_link& link) const NOEXCEPT { // to_block is strong but not necessarily confirmed. - const auto block_fk = to_block(link); - if (!is_confirmed_block(block_fk)) + const auto fk = to_block(link); + if (!is_confirmed_block(fk)) return false; // False return below implies an integrity error (tx should be indexed). table::txs::get_position txs{ {}, link }; - if (!store_.txs.find(block_fk, txs)) + if (!store_.txs.find(fk, txs)) return false; out = txs.position; @@ -356,6 +356,7 @@ TEMPLATE typename CLASS::inputs_ptr CLASS::get_inputs( const tx_link& link) const NOEXCEPT { + // TODO: eliminate shared memory pointer reallcations. using namespace system; const auto fks = to_tx_spends(link); if (fks.empty()) @@ -375,6 +376,7 @@ TEMPLATE typename CLASS::outputs_ptr CLASS::get_outputs( const tx_link& link) const NOEXCEPT { + // TODO: eliminate shared memory pointer reallcations. using namespace system; const auto fks = to_tx_outputs(link); if (fks.empty()) @@ -394,6 +396,7 @@ TEMPLATE typename CLASS::transactions_ptr CLASS::get_transactions( const header_link& link) const NOEXCEPT { + // TODO: eliminate shared memory pointer reallcations. using namespace system; const auto txs = to_transactions(link); if (txs.empty()) @@ -502,6 +505,7 @@ TEMPLATE typename CLASS::transaction::cptr CLASS::get_transaction( const tx_link& link) const NOEXCEPT { + // TODO: eliminate shared memory pointer reallcations. using namespace system; table::transaction::only_with_sk tx{}; if (!store_.tx.get(link, tx)) @@ -601,6 +605,7 @@ typename CLASS::inputs_ptr CLASS::get_spenders( const auto spenders = to_shared(); spenders->reserve(spend_fks.size()); + // TODO: eliminate shared memory pointer reallcation. for (const auto& spend_fk: spend_fks) if (!push_bool(*spenders, get_input(spend_fk))) return {}; @@ -676,6 +681,7 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT std_vector spends{}; spends.reserve(ins.size()); + // TODO: eliminate shared memory pointer reallcations. // ======================================================================== const auto scope = store_.get_transactor(); diff --git a/include/bitcoin/database/impl/query/confirm.ipp b/include/bitcoin/database/impl/query/confirm.ipp index e0ff0456..e5aaf176 100644 --- a/include/bitcoin/database/impl/query/confirm.ipp +++ b/include/bitcoin/database/impl/query/confirm.ipp @@ -20,6 +20,7 @@ #define LIBBITCOIN_DATABASE_QUERY_CONFIRM_IPP #include +#include #include #include #include @@ -136,14 +137,14 @@ bool CLASS::is_spent(const spend_link& link) const NOEXCEPT if (spend.is_null()) return false; - return !!spent_prevout(spend.prevout(), spend.parent_fk); + return is_spent_prevout(spend.prevout(), spend.parent_fk); } // unused TEMPLATE bool CLASS::is_strong_spend(const spend_link& link) const NOEXCEPT { - return !to_block(to_spend_tx(link)).is_terminal(); + return is_strong_tx(to_spend_tx(link)); } // unused @@ -235,14 +236,23 @@ code CLASS::locked_prevout(const point_link& link, uint32_t sequence, // protected TEMPLATE -code CLASS::spent_prevout(tx_link link, index index) const NOEXCEPT +bool CLASS::is_spent_prevout(const tx_link& link, index index) const NOEXCEPT { - return spent_prevout(table::spend::compose(link, index), tx_link::terminal); + const auto fp = table::spend::compose(link, index); + return is_spent_prevout(fp, tx_link::terminal); } // protected TEMPLATE -code CLASS::spent_prevout(const foreign_point& point, +bool CLASS::is_spent_prevout(const foreign_point& point, + const tx_link& self) const NOEXCEPT +{ + return spent_prevout(point, self) != error::success; +} + +// protected +TEMPLATE +error::error_t CLASS::spent_prevout(const foreign_point& point, const tx_link& self) const NOEXCEPT { auto it = store_.spend.it(point); @@ -255,8 +265,6 @@ code CLASS::spent_prevout(const foreign_point& point, if (!store_.spend.get(it, spend)) return error::integrity; - // Skip current spend, which is the only one if not double spent. - // If strong spender exists then prevout is confirmed double spent. if ((spend.parent_fk != self) && is_strong_tx(spend.parent_fk)) return error::confirmed_double_spend; } @@ -266,11 +274,10 @@ code CLASS::spent_prevout(const foreign_point& point, // protected TEMPLATE -code CLASS::unspendable_prevout(const point_link& link, +error::error_t CLASS::unspendable_prevout(const point_link& link, uint32_t sequence, uint32_t version, const context& ctx) const NOEXCEPT { - const auto key = get_point_key(link); - const auto strong = to_strong(key); + const auto strong = to_strong(get_point_key(link)); if (strong.block.is_terminal()) return strong.tx.is_terminal() ? error::missing_previous_output : @@ -311,29 +318,31 @@ code CLASS::unspent_duplicates(const tx_link& coinbase, size_t unspent{}; for (const auto& tx: coinbases) for (index out{}; out < output_count(tx); ++out) - if (!spent_prevout(tx, out) && is_one(unspent++)) + if (!is_spent_prevout(tx, out) && is_one(unspent++)) return error::unspent_coinbase_collision; return is_zero(unspent) ? error::integrity : error::success; } +// protected TEMPLATE -code CLASS::tx_confirmable(const tx_link& link, - const context& ctx) const NOEXCEPT +spend_sets CLASS::to_spend_sets(const header_link& link) const NOEXCEPT { - code ec{}; - const auto set = to_spend_set(link); - for (const auto& spend: set.spends) + const auto txs = to_transactions(link); + if (txs.size() <= one) + return {}; + + spend_sets out{ sub1(txs.size()) }; + const auto to_set = [this](const auto& tx) NOEXCEPT { - if ((ec = unspendable_prevout(spend.point_fk, spend.sequence, - set.version, ctx))) - return ec; + return to_spend_set(tx); + }; - if ((ec = spent_prevout(spend.prevout(), link))) - return ec; - } + // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. + std_transform(bc::par_unseq, std::next(txs.begin()), txs.end(), + out.begin(), to_set); - return error::success; + return out; } // split(3) 219 secs for 400k-410k; split(2) 255 and split(0) 456 (not shown). @@ -348,41 +357,86 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT if ((ec = unspent_duplicates(to_coinbase(link), ctx))) return ec; - const auto is_unspendable = [&ctx, this] (const auto& set) NOEXCEPT + std::atomic fault{ error::success }; + const auto is_unspendable = [this, &ctx, &fault](const auto& set) NOEXCEPT { + error::error_t ec{}; for (const auto& spend: set.spends) - if (unspendable_prevout(spend.point_fk, spend.sequence, - set.version, ctx)) + if ((ec = unspendable_prevout(spend.point_fk, spend.sequence, + set.version, ctx))) + { + fault.store(ec); return true; + } return false; }; - const auto is_spent = [this](const auto& set) NOEXCEPT + const auto is_spent = [this, &fault](const auto& set) NOEXCEPT { + error::error_t ec{}; for (const auto& spend: set.spends) - if (spent_prevout(spend.prevout(), set.tx)) + if ((ec = spent_prevout(spend.prevout(), set.tx))) + { + fault.store(ec); return true; + } return false; }; // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. - const auto sets = to_non_coinbase_spends(link); + const auto sets = to_spend_sets(link); // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. if (std_any_of(bc::par_unseq, sets.begin(), sets.end(), is_unspendable)) - return error::integrity; + return { fault.load() }; // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. if (std_any_of(bc::par_unseq, sets.begin(), sets.end(), is_spent)) - return error::integrity; - - return error::success; + return { fault.load() }; + + return ec; } #if defined(UNDEFINED) +// protected +TEMPLATE +spend_sets CLASS::to_spend_sets( + const header_link& link) const NOEXCEPT +{ + const auto txs = to_transactions(link); + if (txs.size() <= one) + return {}; + + spend_sets sets{}; + sets.reserve(sub1(txs.size())); + for (auto tx = std::next(txs.begin()); tx != txs.end(); ++tx) + sets.push_back(to_spend_set(*tx)); + + return sets; +} + +TEMPLATE +code CLASS::tx_confirmable(const tx_link& link, + const context& ctx) const NOEXCEPT +{ + code ec{}; + const auto set = to_spend_set(link); + for (const auto& spend : set.spends) + { + if ((ec = unspendable_prevout(spend.point_fk, spend.sequence, + set.version, ctx))) + return ec; + + if (is_spent_prevout(spend.prevout(), link)) + return error::confirmed_double_spend; + } + + return error::success; +} + // split(0) 403 secs for 400k-410k TEMPLATE code CLASS::block_confirmable(const header_link& link) const NOEXCEPT @@ -418,7 +472,7 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT if ((ec = unspent_duplicates(to_coinbase(link), ctx))) return ec; - const auto sets = to_non_coinbase_spends(link); + const auto sets = to_spend_sets(link); for (const auto& set: sets) { for (const auto& spend: set.spends) @@ -427,8 +481,8 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT set.version, ctx))) return ec; - if ((ec = spent_prevout(spend.prevout(), set.tx))) - return ec; + if (is_spent_prevout(spend.prevout(), set.tx)) + return error::confirmed_double_spend; } } @@ -447,7 +501,7 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT if ((ec = unspent_duplicates(to_coinbase(link), ctx))) return ec; - const auto sets = to_non_coinbase_spends(link); + const auto sets = to_spend_sets(link); for (const auto& set: sets) for (const auto& spend: set.spends) if ((ec = unspendable_prevout(spend.point_fk, spend.sequence, @@ -458,8 +512,8 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT for (const auto& set: sets) for (const auto& spend: set.spends) - if ((ec = spent_prevout(spend.prevout(), set.tx))) - return ec; + if (is_spent_prevout(spend.prevout(), set.tx)) + return error::confirmed_double_spend; return ec; } @@ -471,18 +525,19 @@ TEMPLATE bool CLASS::set_strong(const header_link& link, const tx_links& txs, bool positive) NOEXCEPT { - return std::all_of(txs.begin(), txs.end(), [&](const tx_link& fk) NOEXCEPT + const auto set = [this, &link, positive](const tx_link& tx) NOEXCEPT { - // If under checkpoint txs is set later, so under fault will reoccur. - // Otherwise confirmed by height is set later so will also reoccur. - // Confirmation by height always sequential so can be no inconsistency. - return store_.strong_tx.put(fk, table::strong_tx::record + // TODO: eliminate shared memory pointer reallcation. + return store_.strong_tx.put(tx, table::strong_tx::record { {}, link, positive }); - }); + }; + + // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. + return std_all_of(bc::par_unseq, txs.begin(), txs.end(), set); } TEMPLATE diff --git a/include/bitcoin/database/impl/query/translate.ipp b/include/bitcoin/database/impl/query/translate.ipp index 065c0723..f743f2a7 100644 --- a/include/bitcoin/database/impl/query/translate.ipp +++ b/include/bitcoin/database/impl/query/translate.ipp @@ -202,13 +202,10 @@ TEMPLATE header_link CLASS::to_block(const tx_link& link) const NOEXCEPT { table::strong_tx::record strong{}; - if (!store_.strong_tx.find(link, strong)) + if (!store_.strong_tx.find(link, strong) || !strong.positive) return {}; - // Terminal implies not strong (false). - if (!strong.positive) - return {}; - + // Terminal implies not strong (not in block). return strong.header_fk; } @@ -282,7 +279,7 @@ inline tx_links CLASS::to_strong_txs(const tx_link& link) const NOEXCEPT !contains(pairs, strong.header_fk)) { #if defined(HAVE_CLANG) - // Work around clang emplace_back bug (no matching constructor). + // emplace_back aggregate initialization requires clang 16. pairs.push_back({ strong.header_fk, it.self(), strong.positive }); #else pairs.emplace_back(strong.header_fk, it.self(), strong.positive); @@ -481,7 +478,7 @@ spend_set CLASS::to_spend_set(const tx_link& link) const NOEXCEPT spend_set set{ link, tx.version, {} }; set.spends.reserve(tx.ins_count); - // This is not concurrent because to_non_coinbase_spends is (by tx). + // This is not concurrent because to_spend_sets is (by tx). table::spend::get_prevout_sequence get{}; for (const auto& spend_fk: puts.spend_fks) { @@ -490,7 +487,7 @@ spend_set CLASS::to_spend_set(const tx_link& link) const NOEXCEPT // Translate query to public struct. #if defined(HAVE_CLANG) - // Work around clang emplace_back bug (no matching constructor). + // emplace_back aggregate initialization requires clang 16. set.spends.push_back({ get.point_fk, get.point_index, get.sequence }); #else set.spends.emplace_back(get.point_fk, get.point_index, get.sequence); @@ -523,47 +520,6 @@ tx_link CLASS::to_coinbase(const header_link& link) const NOEXCEPT return txs.coinbase_fk; } -// protected -TEMPLATE -spend_sets CLASS::to_non_coinbase_spends( - const header_link& link) const NOEXCEPT -{ - const auto txs = to_transactions(link); - if (txs.size() <= one) - return {}; - - spend_sets out{ sub1(txs.size()) }; - const auto to_set = [this](const auto& tx) NOEXCEPT - { - return to_spend_set(tx); - }; - - // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++. - std_transform(bc::par_unseq, std::next(txs.begin()), txs.end(), - out.begin(), to_set); - - return out; -} - -#if defined(UNDEFINED) -// protected -TEMPLATE -spend_sets CLASS::to_non_coinbase_spends( - const header_link& link) const NOEXCEPT -{ - const auto txs = to_transactions(link); - if (txs.size() <= one) - return {}; - - spend_sets sets{}; - sets.reserve(sub1(txs.size())); - for (auto tx = std::next(txs.begin()); tx != txs.end(); ++tx) - sets.push_back(to_spend_set(*tx)); - - return sets; -} -#endif - TEMPLATE spend_links CLASS::to_block_spends(const header_link& link) const NOEXCEPT { @@ -572,7 +528,7 @@ spend_links CLASS::to_block_spends(const header_link& link) const NOEXCEPT for (const auto& tx: txs) { - const auto tx_spends = to_tx_spenders(tx); + const auto tx_spends = to_tx_spends(tx); spends.insert(spends.end(), tx_spends.begin(), tx_spends.end()); } diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 6fbd8b03..d73d89cf 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -486,7 +486,9 @@ class query bool set_strong(const header_link& link) NOEXCEPT; bool set_unstrong(const header_link& link) NOEXCEPT; code block_confirmable(const header_link& link) const NOEXCEPT; +#if defined(UNDEFINED) code tx_confirmable(const tx_link& link, const context& ctx) const NOEXCEPT; +#endif code unspent_duplicates(const tx_link& coinbase, const context& ctx) const NOEXCEPT; @@ -522,7 +524,7 @@ class query /// ----------------------------------------------------------------------- spend_set to_spend_set(const tx_link& link) const NOEXCEPT; - spend_sets to_non_coinbase_spends(const header_link& link) const NOEXCEPT; + spend_sets to_spend_sets(const header_link& link) const NOEXCEPT; uint32_t to_spend_index(const tx_link& parent_fk, const spend_link& input_fk) const NOEXCEPT; @@ -555,10 +557,12 @@ class query const context& ctx) const NOEXCEPT; // Critical path - code spent_prevout(tx_link link, index index) const NOEXCEPT; - code spent_prevout(const foreign_point& point, + bool is_spent_prevout(const tx_link& link, index index) const NOEXCEPT; + bool is_spent_prevout(const foreign_point& point, + const tx_link& self) const NOEXCEPT; + error::error_t spent_prevout(const foreign_point& point, const tx_link& self) const NOEXCEPT; - code unspendable_prevout(const point_link& link, + error::error_t unspendable_prevout(const point_link& link, uint32_t sequence, uint32_t version, const context& ctx) const NOEXCEPT; bool set_strong(const header_link& link, const tx_links& txs, diff --git a/include/bitcoin/database/tables/schema.hpp b/include/bitcoin/database/tables/schema.hpp index 286a1ffc..aa6f1e4f 100644 --- a/include/bitcoin/database/tables/schema.hpp +++ b/include/bitcoin/database/tables/schema.hpp @@ -58,6 +58,7 @@ namespace schema constexpr auto candidate = "candidate"; constexpr auto confirmed = "confirmed"; constexpr auto strong_tx = "strong_tx"; + ////constexpr auto spent_out = "spent_out"; } namespace caches @@ -70,8 +71,6 @@ namespace schema { constexpr auto address = "address"; constexpr auto neutrino = "neutrino"; - ////constexpr auto bootstrap = "bootstrap"; - ////constexpr auto buffer = "buffer"; } namespace locks diff --git a/src/error.cpp b/src/error.cpp index a0b79285..f92c6224 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -103,8 +103,8 @@ DEFINE_ERROR_T_MESSAGE_MAP(error) { tx_point_put, "tx_point_put" }, { tx_spend_set, "tx_spend_set" }, { tx_output_put, "tx_output_put" }, - { tx_tx_set, "tx_tx_set" }, { tx_puts_put, "tx_puts_put" }, + { tx_tx_set, "tx_tx_set" }, { tx_spend_commit, "tx_spend_commit" }, { tx_address_put, "tx_address_put" }, { tx_tx_commit, "tx_tx_commit" }, @@ -113,10 +113,10 @@ DEFINE_ERROR_T_MESSAGE_MAP(error) { header_put, "header_put" }, // txs archive - { txs_empty, "txs_empty" }, { txs_header, "txs_header" }, - { txs_txs_put, "txs_txs_put" }, - { txs_confirm, "txs_confirm" } + { txs_empty, "txs_empty" }, + { txs_confirm, "txs_confirm" }, + { txs_txs_put, "txs_txs_put" } }; DEFINE_ERROR_T_CATEGORY(error, "database", "database code") diff --git a/test/error.cpp b/test/error.cpp index b88bd5b2..606870c5 100644 --- a/test/error.cpp +++ b/test/error.cpp @@ -547,22 +547,22 @@ BOOST_AUTO_TEST_CASE(error_t__code__tx_output_put__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "tx_output_put"); } -BOOST_AUTO_TEST_CASE(error_t__code__tx_tx_set__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__tx_puts_put__true_exected_message) { - constexpr auto value = error::tx_tx_set; + constexpr auto value = error::tx_puts_put; const auto ec = code(value); BOOST_REQUIRE(ec); BOOST_REQUIRE(ec == value); - BOOST_REQUIRE_EQUAL(ec.message(), "tx_tx_set"); + BOOST_REQUIRE_EQUAL(ec.message(), "tx_puts_put"); } -BOOST_AUTO_TEST_CASE(error_t__code__tx_puts_put__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__tx_tx_set__true_exected_message) { - constexpr auto value = error::tx_puts_put; + constexpr auto value = error::tx_tx_set; const auto ec = code(value); BOOST_REQUIRE(ec); BOOST_REQUIRE(ec == value); - BOOST_REQUIRE_EQUAL(ec.message(), "tx_puts_put"); + BOOST_REQUIRE_EQUAL(ec.message(), "tx_tx_set"); } BOOST_AUTO_TEST_CASE(error_t__code__tx_spend_commit__true_exected_message) @@ -623,22 +623,22 @@ BOOST_AUTO_TEST_CASE(error_t__code__txs_empty__true_exected_message) BOOST_REQUIRE_EQUAL(ec.message(), "txs_empty"); } -BOOST_AUTO_TEST_CASE(error_t__code__txs_txs_put__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__txs_confirm__true_exected_message) { - constexpr auto value = error::txs_txs_put; + constexpr auto value = error::txs_confirm; const auto ec = code(value); BOOST_REQUIRE(ec); BOOST_REQUIRE(ec == value); - BOOST_REQUIRE_EQUAL(ec.message(), "txs_txs_put"); + BOOST_REQUIRE_EQUAL(ec.message(), "txs_confirm"); } -BOOST_AUTO_TEST_CASE(error_t__code__txs_confirm__true_exected_message) +BOOST_AUTO_TEST_CASE(error_t__code__txs_txs_put__true_exected_message) { - constexpr auto value = error::txs_confirm; + constexpr auto value = error::txs_txs_put; const auto ec = code(value); BOOST_REQUIRE(ec); BOOST_REQUIRE(ec == value); - BOOST_REQUIRE_EQUAL(ec.message(), "txs_confirm"); + BOOST_REQUIRE_EQUAL(ec.message(), "txs_txs_put"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/test/query/translate.cpp b/test/query/translate.cpp index 31f98823..b3b13d51 100644 --- a/test/query/translate.cpp +++ b/test/query/translate.cpp @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(query_translate__to_tx__txs__expected) BOOST_REQUIRE_EQUAL(query.to_tx(test::block3.transactions_ptr()->front()->hash(true)), tx_link::terminal); } -// to_spend_tx/to_spend/to_tx_spends/to_spend_key/to_non_coinbase_spends +// to_spend_tx/to_spend/to_tx_spends/to_spend_key/to_spend_sets class accessor : public test::query_accessor @@ -227,9 +227,9 @@ class accessor { return test::query_accessor::to_spend_set(link); } - spend_sets to_non_coinbase_spends_(const header_link& link) const NOEXCEPT + spend_sets to_spend_sets_(const header_link& link) const NOEXCEPT { - return test::query_accessor::to_non_coinbase_spends(link); + return test::query_accessor::to_spend_sets(link); } }; @@ -325,11 +325,11 @@ BOOST_AUTO_TEST_CASE(query_translate__to_spend_tx__to_spend__expected) BOOST_REQUIRE_EQUAL(spends.version, test::block1a.transactions_ptr()->front()->version()); // TODO: All blocks have one transaction. - BOOST_REQUIRE(query.to_non_coinbase_spends_(0).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(1).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(2).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(3).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(4).empty()); + BOOST_REQUIRE(query.to_spend_sets_(0).empty()); + BOOST_REQUIRE(query.to_spend_sets_(1).empty()); + BOOST_REQUIRE(query.to_spend_sets_(2).empty()); + BOOST_REQUIRE(query.to_spend_sets_(3).empty()); + BOOST_REQUIRE(query.to_spend_sets_(4).empty()); // Past end. BOOST_REQUIRE_EQUAL(query.to_spend_tx(7), tx_link::terminal); @@ -337,7 +337,7 @@ BOOST_AUTO_TEST_CASE(query_translate__to_spend_tx__to_spend__expected) BOOST_REQUIRE_EQUAL(query.to_spend_key(spend_link::terminal), foreign_point{}); BOOST_REQUIRE_EQUAL(query.to_spend_key(query.to_spend(5, 0)), foreign_point{}); BOOST_REQUIRE(query.to_tx_spends(5).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(5).empty()); + BOOST_REQUIRE(query.to_spend_sets_(5).empty()); // Verify expectations. const auto spend_head = base16_chunk @@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(query_translate__to_spend_tx__to_spend__expected) BOOST_REQUIRE_EQUAL(store.input_body(), input_body); } -BOOST_AUTO_TEST_CASE(query_translate__to_non_coinbase_spends__populated__expected) +BOOST_AUTO_TEST_CASE(query_translate__to_spend_sets__populated__expected) { settings settings{}; settings.path = TEST_DIRECTORY; @@ -430,9 +430,9 @@ BOOST_AUTO_TEST_CASE(query_translate__to_non_coinbase_spends__populated__expecte // coinbase only (null and first). BOOST_REQUIRE(query.initialize(test::genesis)); - BOOST_REQUIRE(query.to_non_coinbase_spends_(0).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(1).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(2).empty()); + BOOST_REQUIRE(query.to_spend_sets_(0).empty()); + BOOST_REQUIRE(query.to_spend_sets_(1).empty()); + BOOST_REQUIRE(query.to_spend_sets_(2).empty()); BOOST_REQUIRE_EQUAL(store.point_body(), system::base16_chunk("")); BOOST_REQUIRE_EQUAL(store.spend_body(), @@ -444,9 +444,9 @@ BOOST_AUTO_TEST_CASE(query_translate__to_non_coinbase_spends__populated__expecte // coinbase only (null and first). BOOST_REQUIRE(query.set(test::block1b, context{ 0, 1, 0 }, false, false)); - BOOST_REQUIRE(query.to_non_coinbase_spends_(0).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(1).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(2).empty()); + BOOST_REQUIRE(query.to_spend_sets_(0).empty()); + BOOST_REQUIRE(query.to_spend_sets_(1).empty()); + BOOST_REQUIRE(query.to_spend_sets_(2).empty()); BOOST_REQUIRE_EQUAL(store.point_body(), system::base16_chunk("")); BOOST_REQUIRE_EQUAL(store.spend_body(), @@ -462,8 +462,8 @@ BOOST_AUTO_TEST_CASE(query_translate__to_non_coinbase_spends__populated__expecte // 2 inputs (block1b and tx2b). BOOST_REQUIRE(query.set(test::block_spend_internal_2b, context{ 0, 101, 0 }, false, false)); - BOOST_REQUIRE(query.to_non_coinbase_spends_(0).empty()); - BOOST_REQUIRE(query.to_non_coinbase_spends_(1).empty()); + BOOST_REQUIRE(query.to_spend_sets_(0).empty()); + BOOST_REQUIRE(query.to_spend_sets_(1).empty()); // Two points because non-null, but only one is non-first (also coinbase criteria). // block_spend_internal_2b first tx (tx2b) is first but with non-null input. @@ -488,8 +488,8 @@ BOOST_AUTO_TEST_CASE(query_translate__to_non_coinbase_spends__populated__expecte "02000000""b1""0179" "03000000""b2""0179")); - // to_non_coinbase_spends keys on first-tx-ness, so only one input despite two points (second point). - const auto spends = query.to_non_coinbase_spends_(2); + // to_spend_sets keys on first-tx-ness, so only one input despite two points (second point). + const auto spends = query.to_spend_sets_(2); BOOST_REQUIRE_EQUAL(spends.size(), 1u); ////BOOST_REQUIRE_EQUAL(spends.front().spend_fks.size(), 1u); ////BOOST_REQUIRE_EQUAL(spends.front().spend_fks, spend_links{ 3 });