From e7158363165d9573256acc0ce44e2ffe9be1b65f Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 25 May 2024 22:43:35 -0400 Subject: [PATCH 1/5] Add to_filter() and use it to GUARD set_filter(...). --- include/bitcoin/database/impl/query/optional.ipp | 5 +++++ include/bitcoin/database/impl/query/translate.ipp | 10 ++++++++-- include/bitcoin/database/query.hpp | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/bitcoin/database/impl/query/optional.ipp b/include/bitcoin/database/impl/query/optional.ipp index 380bb99a..6ea56509 100644 --- a/include/bitcoin/database/impl/query/optional.ipp +++ b/include/bitcoin/database/impl/query/optional.ipp @@ -202,6 +202,11 @@ TEMPLATE bool CLASS::set_filter(const header_link& link, const hash_digest& filter_head, const filter& filter) NOEXCEPT { + // GUARD (filter redundancy) + // This is only fully effective if there is a single database thread. + if (!to_filter(link).is_terminal()) + return true; + // ======================================================================== const auto scope = store_.get_transactor(); diff --git a/include/bitcoin/database/impl/query/translate.ipp b/include/bitcoin/database/impl/query/translate.ipp index 509c15b2..29cf1667 100644 --- a/include/bitcoin/database/impl/query/translate.ipp +++ b/include/bitcoin/database/impl/query/translate.ipp @@ -81,9 +81,15 @@ inline tx_link CLASS::to_tx(const hash_digest& key) const NOEXCEPT } TEMPLATE -inline txs_link CLASS::to_txs_link(const header_link& link) const NOEXCEPT +inline txs_link CLASS::to_txs_link(const header_link& key) const NOEXCEPT { - return store_.txs.first(link); + return store_.txs.first(key); +} + +TEMPLATE +inline filter_link CLASS::to_filter(const header_link& key) const NOEXCEPT +{ + return store_.neutrino.first(key); } // put to tx (reverse navigation) diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 777b7521..863b54dc 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -41,6 +41,7 @@ using point_link = table::point::link; using spend_link = table::spend::link; using txs_link = table::txs::link; using tx_link = table::transaction::link; +using filter_link = table::neutrino::link; using header_links = std_vector; using tx_links = std_vector; @@ -229,7 +230,8 @@ class query inline header_link to_header(const hash_digest& key) const NOEXCEPT; inline point_link to_point(const hash_digest& key) const NOEXCEPT; inline tx_link to_tx(const hash_digest& key) const NOEXCEPT; - inline txs_link to_txs_link(const header_link& link) const NOEXCEPT; + inline txs_link to_txs_link(const header_link& key) const NOEXCEPT; + inline filter_link to_filter(const header_link& key) const NOEXCEPT; /// put to tx (reverse navigation) tx_link to_spend_tx(const spend_link& link) const NOEXCEPT; From 7f1c9739281d547c46f72231cbd6c2651d081950 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 27 May 2024 15:32:21 -0400 Subject: [PATCH 2/5] Disable insert guards, these are the cause of sync thrash. --- .../bitcoin/database/impl/query/archive.ipp | 58 ++++++++++--------- .../bitcoin/database/impl/query/optional.ipp | 8 +-- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/include/bitcoin/database/impl/query/archive.ipp b/include/bitcoin/database/impl/query/archive.ipp index f2a48753..a4c9aa80 100644 --- a/include/bitcoin/database/impl/query/archive.ipp +++ b/include/bitcoin/database/impl/query/archive.ipp @@ -675,11 +675,11 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT const auto key = tx.hash(false); - // GUARD (tx redundancy) - // This is only fully effective if there is a single database thread. - out_fk = to_tx(key); - if (!out_fk.is_terminal()) - return error::success; + ////// GUARD (tx redundancy) + ////// This is only fully effective if there is a single database thread. + ////out_fk = to_tx(key); + ////if (!out_fk.is_terminal()) + //// return error::success; // Declare puts record. const auto& ins = *tx.inputs_ptr(); @@ -731,17 +731,23 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT point_link hash_fk{}; if (hash != null_hash) { - hash_fk = to_point(hash); - if (hash_fk.is_terminal()) + // TODO: look into point table removal or conditional duplicates. + // TODO: allowing duplication here increases store by 45GiB. + + ////// GUARD (tx redundancy) + ////// Only fully effective if there is a single database thread. + ////hash_fk = to_point(hash); + ////if (hash_fk.is_terminal()) + ////{ + // Safe allocation failure, duplicates [limited but] expected. + if (!store_.point.put_link(hash_fk, hash, table::point::record { - // Safe allocation failure, duplicates limited but expected. - if (!store_.point.put_link(hash_fk, hash, table::point::record - { - })) - { - return error::tx_point_put; - } + // Table stores no data other than the search key. + })) + { + return error::tx_point_put; } + ////} } // Accumulate spend keys in order (terminal for any null point). @@ -875,11 +881,11 @@ header_link CLASS::set_link(const header& header, const context& ctx) NOEXCEPT { const auto key = header.hash(); - // GUARD (header redundancy) - // This is only fully effective if there is a single database thread. - auto header_fk = to_header(key); - if (!header_fk.is_terminal()) - return header_fk; + ////// GUARD (header redundancy) + ////// This is only fully effective if there is a single database thread. + ////auto header_fk = to_header(key); + ////if (!header_fk.is_terminal()) + //// return header_fk; // Parent must be missing iff its hash is null. const auto& parent_sk = header.previous_block_hash(); @@ -953,13 +959,13 @@ code CLASS::set_code(txs_link& out_fk, const transactions& txs, if (key.is_terminal()) return error::txs_header; - // GUARD (block (txs) redundancy) - // This is only fully effective if there is a single database thread. - // Guard must be lifted for an existing top malleable association so - // that a non-malleable association may be accomplished. - out_fk = to_txs_link(key); - if (!out_fk.is_terminal() && !is_malleable(key)) - return error::success; + ////// GUARD (block (txs) redundancy) + ////// This is only fully effective if there is a single database thread. + ////// Guard must be lifted for an existing top malleable association so + ////// that a non-malleable association may be accomplished. + ////out_fk = to_txs_link(key); + ////if (!out_fk.is_terminal() && !is_malleable(key)) + //// return error::success; code ec{}; tx_link tx_fk{}; diff --git a/include/bitcoin/database/impl/query/optional.ipp b/include/bitcoin/database/impl/query/optional.ipp index 6ea56509..248689de 100644 --- a/include/bitcoin/database/impl/query/optional.ipp +++ b/include/bitcoin/database/impl/query/optional.ipp @@ -202,10 +202,10 @@ TEMPLATE bool CLASS::set_filter(const header_link& link, const hash_digest& filter_head, const filter& filter) NOEXCEPT { - // GUARD (filter redundancy) - // This is only fully effective if there is a single database thread. - if (!to_filter(link).is_terminal()) - return true; + ////// GUARD (filter redundancy) + ////// This is only fully effective if there is a single database thread. + ////if (!to_filter(link).is_terminal()) + //// return true; // ======================================================================== const auto scope = store_.get_transactor(); From aef7c2f8b50a36df97b1ec382855b1056521e256 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 27 May 2024 18:41:27 -0400 Subject: [PATCH 3/5] Add database setting .minimize. --- include/bitcoin/database/settings.hpp | 1 + src/settings.cpp | 1 + test/settings.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/include/bitcoin/database/settings.hpp b/include/bitcoin/database/settings.hpp index 1b6ffea1..f481b80b 100644 --- a/include/bitcoin/database/settings.hpp +++ b/include/bitcoin/database/settings.hpp @@ -38,6 +38,7 @@ struct BCD_API settings /// Properties. std::filesystem::path path; + bool minimize; /// Archives. /// ----------------------------------------------------------------------- diff --git a/src/settings.cpp b/src/settings.cpp index f508ede0..955e0aa6 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -28,6 +28,7 @@ using namespace bc::system; settings::settings() NOEXCEPT : path{ "bitcoin" }, + minimize(true), // Archives. diff --git a/test/settings.cpp b/test/settings.cpp index 49b49e8c..94cf93c3 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -24,6 +24,7 @@ BOOST_AUTO_TEST_CASE(settings__construct__default__expected) { database::settings configuration; BOOST_REQUIRE_EQUAL(configuration.path, "bitcoin"); + BOOST_REQUIRE(configuration.minimize); // Archives. BOOST_REQUIRE_EQUAL(configuration.header_buckets, 100u); From f5c7406909c96db2f5bbeb435b2c25ccd70cd675 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 27 May 2024 18:42:31 -0400 Subject: [PATCH 4/5] Implement minimize setting. --- .../bitcoin/database/impl/query/archive.ipp | 32 ++++++++++--------- include/bitcoin/database/impl/query/query.ipp | 4 +-- include/bitcoin/database/impl/store.ipp | 6 ++++ include/bitcoin/database/query.hpp | 4 ++- include/bitcoin/database/store.hpp | 3 ++ 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/include/bitcoin/database/impl/query/archive.ipp b/include/bitcoin/database/impl/query/archive.ipp index a4c9aa80..63ee3d8f 100644 --- a/include/bitcoin/database/impl/query/archive.ipp +++ b/include/bitcoin/database/impl/query/archive.ipp @@ -731,23 +731,25 @@ code CLASS::set_code(tx_link& out_fk, const transaction& tx) NOEXCEPT point_link hash_fk{}; if (hash != null_hash) { - // TODO: look into point table removal or conditional duplicates. - // TODO: allowing duplication here increases store by 45GiB. - - ////// GUARD (tx redundancy) - ////// Only fully effective if there is a single database thread. - ////hash_fk = to_point(hash); - ////if (hash_fk.is_terminal()) - ////{ - // Safe allocation failure, duplicates [limited but] expected. - if (!store_.point.put_link(hash_fk, hash, table::point::record + // TODO: look into point table removal. + if (minimize_) { - // Table stores no data other than the search key. - })) - { - return error::tx_point_put; + // GUARD (tx redundancy) + // Only fully effective if there is a single database thread. + // This reduces point store by ~45GiB, but causes thrashing. + hash_fk = to_point(hash); + if (hash_fk.is_terminal()) + { + // Safe allocation failure, duplicates limited but expected. + if (!store_.point.put_link(hash_fk, hash, table::point::record + { + // Table stores no data other than the search key. + })) + { + return error::tx_point_put; + } + } } - ////} } // Accumulate spend keys in order (terminal for any null point). diff --git a/include/bitcoin/database/impl/query/query.ipp b/include/bitcoin/database/impl/query/query.ipp index 7ebc8ffc..817fdb5b 100644 --- a/include/bitcoin/database/impl/query/query.ipp +++ b/include/bitcoin/database/impl/query/query.ipp @@ -69,8 +69,8 @@ namespace libbitcoin { namespace database { TEMPLATE -CLASS::query(Store& value) NOEXCEPT - : store_(value) +CLASS::query(Store& store) NOEXCEPT + : store_(store), minimize_(store.minimize()) { } diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index b401fc6f..01025bac 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -1115,6 +1115,12 @@ void CLASS::report(const error_handler& handler) const NOEXCEPT ////report(buffer_body_, table_t::buffer_body); } +TEMPLATE +bool CLASS::minimize() const NOEXCEPT +{ + return configuration_.minimize; +} + BC_POP_WARNING() } // namespace database diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 863b54dc..2f8cf8a1 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -81,7 +81,7 @@ class query using heights = std_vector; using filter = system::data_chunk; - query(Store& value) NOEXCEPT; + query(Store& store) NOEXCEPT; /// Store management from query-holder (not store owner) context. /// ----------------------------------------------------------------------- @@ -537,7 +537,9 @@ class query static inline bool contains(const block_txs& blocks, const block_tx& block) NOEXCEPT; + // These are thread safe. Store& store_; + bool minimize_; }; } // namespace database diff --git a/include/bitcoin/database/store.hpp b/include/bitcoin/database/store.hpp index 098042d7..3ca69a18 100644 --- a/include/bitcoin/database/store.hpp +++ b/include/bitcoin/database/store.hpp @@ -91,6 +91,9 @@ class store /// Dump all error/full conditions to handler. void report(const error_handler& handler) const NOEXCEPT; + /// Favor minimum size over thrashing guard (requires high memory). + bool minimize() const NOEXCEPT; + /// Tables. /// ----------------------------------------------------------------------- From 6b9c6b05126e6ed793aa93d5cf2a589ac6d1570b Mon Sep 17 00:00:00 2001 From: evoskuil Date: Mon, 27 May 2024 18:44:38 -0400 Subject: [PATCH 5/5] Update tests for non-system::error success code returns. --- test/query/archive.cpp | 182 +++++++++++++++++++++-------------------- 1 file changed, 92 insertions(+), 90 deletions(-) diff --git a/test/query/archive.cpp b/test/query/archive.cpp index 46de90f3..a0be6ebf 100644 --- a/test/query/archive.cpp +++ b/test/query/archive.cpp @@ -49,49 +49,51 @@ const auto events_handler = [](auto, auto) {}; // archive (natural-keyed) // slow test (mmap) -////BOOST_AUTO_TEST_CASE(query_archive__set_header__mmap_get_header__expected) -////{ -//// constexpr auto parent = system::null_hash; -//// constexpr auto merkle_root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); -//// constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); -//// const system::chain::header header -//// { -//// 0x31323334, // version -//// parent, // previous_block_hash -//// merkle_root,// merkle_root -//// 0x41424344, // timestamp -//// 0x51525354, // bits -//// 0x61626364 // nonce -//// }; -//// -//// settings settings{}; -//// settings.header_buckets = 10; -//// settings.path = TEST_DIRECTORY; -//// store store{ settings }; -//// query> query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); -//// -//// BOOST_REQUIRE(query.set(header, test::context)); -//// -//// table::header::record element1{}; -//// BOOST_REQUIRE(store.header.get(query.to_header(block_hash), element1)); -//// -//// const auto pointer = query.get_header(query.to_header(block_hash)); -//// BOOST_REQUIRE(pointer); -//// BOOST_REQUIRE(*pointer == header); -//// -//// // must open/close mmap -//// BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); -//// BOOST_REQUIRE_EQUAL(element1.ctx.height, system::mask_left(test::context.height, byte_bits)); -//// BOOST_REQUIRE_EQUAL(element1.ctx.flags, test::context.flags); -//// BOOST_REQUIRE_EQUAL(element1.ctx.mtp, test::context.mtp); -//// BOOST_REQUIRE_EQUAL(element1.version, header.version()); -//// BOOST_REQUIRE_EQUAL(element1.parent_fk, linkage::terminal); -//// BOOST_REQUIRE_EQUAL(element1.merkle_root, header.merkle_root()); -//// BOOST_REQUIRE_EQUAL(element1.timestamp, header.timestamp()); -//// BOOST_REQUIRE_EQUAL(element1.bits, header.bits()); -//// BOOST_REQUIRE_EQUAL(element1.nonce, header.nonce()); -////} +#if defined(UNDEFINED) +BOOST_AUTO_TEST_CASE(query_archive__set_header__mmap_get_header__expected) +{ + constexpr auto parent = system::null_hash; + constexpr auto merkle_root = system::base16_array("119192939495969798999a9b9c9d9e9f229192939495969798999a9b9c9d9e9f"); + constexpr auto block_hash = system::base16_array("85d0b02a16f6d645aa865fad4a8666f5e7bb2b0c4392a5d675496d6c3defa1f2"); + const system::chain::header header + { + 0x31323334, // version + parent, // previous_block_hash + merkle_root,// merkle_root + 0x41424344, // timestamp + 0x51525354, // bits + 0x61626364 // nonce + }; + + settings settings{}; + settings.header_buckets = 10; + settings.path = TEST_DIRECTORY; + store store{ settings }; + query> query{ store }; + BOOST_REQUIRE(!store.create(events_handler)); + + BOOST_REQUIRE(query.set(header, test::context)); + + table::header::record element1{}; + BOOST_REQUIRE(store.header.get(query.to_header(block_hash), element1)); + + const auto pointer = query.get_header(query.to_header(block_hash)); + BOOST_REQUIRE(pointer); + BOOST_REQUIRE(*pointer == header); + + // must open/close mmap + BOOST_REQUIRE(!store.close(events_handler)); + BOOST_REQUIRE_EQUAL(element1.ctx.height, system::mask_left(test::context.height, byte_bits)); + BOOST_REQUIRE_EQUAL(element1.ctx.flags, test::context.flags); + BOOST_REQUIRE_EQUAL(element1.ctx.mtp, test::context.mtp); + BOOST_REQUIRE_EQUAL(element1.version, header.version()); + BOOST_REQUIRE_EQUAL(element1.parent_fk, linkage::terminal); + BOOST_REQUIRE_EQUAL(element1.merkle_root, header.merkle_root()); + BOOST_REQUIRE_EQUAL(element1.timestamp, header.timestamp()); + BOOST_REQUIRE_EQUAL(element1.bits, header.bits()); + BOOST_REQUIRE_EQUAL(element1.nonce, header.nonce()); +} +#endif BOOST_AUTO_TEST_CASE(query_archive__set_link_header__is_header__expected) { @@ -139,7 +141,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_link_header__is_header__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); // store open/close flushes record count to head. BOOST_REQUIRE(!query.is_header(header.hash())); @@ -149,7 +151,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_link_header__is_header__expected) BOOST_REQUIRE(!query.is_associated(0)); table::header::record element1{}; BOOST_REQUIRE(store.header.get(query.to_header(block_hash), element1)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.header_head(), expected_header_head); BOOST_REQUIRE_EQUAL(store.header_body(), expected_header_body); @@ -190,11 +192,11 @@ BOOST_AUTO_TEST_CASE(query_archive__set_tx__empty__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); // store open/close flushes record count to heads. BOOST_REQUIRE(!query.set(tx)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.tx_head(), expected_head4_hash); BOOST_REQUIRE_EQUAL(store.point_head(), expected_head4_hash); BOOST_REQUIRE_EQUAL(store.input_head(), expected_head5_array); @@ -287,11 +289,11 @@ BOOST_AUTO_TEST_CASE(query_archive__set_link_tx__null_input__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); const auto link = query.set_link(tx); BOOST_REQUIRE(!link.is_terminal()); ////BOOST_REQUIRE_EQUAL(query.set_link(tx), link); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.tx_head(), expected_tx_head); BOOST_REQUIRE_EQUAL(store.point_head(), expected_point_head); @@ -426,7 +428,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_tx__get_tx__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(!query.is_tx(tx.hash(false))); BOOST_REQUIRE(query.set(tx)); BOOST_REQUIRE(query.is_tx(tx.hash(false))); @@ -435,7 +437,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_tx__get_tx__expected) BOOST_REQUIRE(pointer1); BOOST_REQUIRE(*pointer1 == tx); BOOST_REQUIRE_EQUAL(pointer1->hash(false), tx_hash); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.tx_head(), expected_tx_head); BOOST_REQUIRE_EQUAL(store.point_head(), expected_point_head); @@ -558,7 +560,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block__get_block__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); // Set block (header/txs). BOOST_REQUIRE(!query.is_block(test::genesis.hash())); @@ -573,7 +575,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block__get_block__expected) table::header::record element1{}; BOOST_REQUIRE(store.header.get(query.to_header(test::genesis.hash()), element1)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.header_head(), genesis_header_head); BOOST_REQUIRE_EQUAL(store.tx_head(), genesis_tx_head); @@ -707,7 +709,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block_txs__get_block__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); // Set header and then txs. BOOST_REQUIRE(!query.is_block(test::genesis.hash())); @@ -725,7 +727,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block_txs__get_block__expected) table::header::record element1{}; BOOST_REQUIRE(store.header.get(query.to_header(test::genesis.hash()), element1)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); BOOST_REQUIRE_EQUAL(store.header_head(), genesis_header_head); BOOST_REQUIRE_EQUAL(store.tx_head(), genesis_tx_head); @@ -769,7 +771,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block_txs__get_block__expected) //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(events_handler)); //// //// // Assemble block. //// BOOST_REQUIRE(query.set(test::genesis.header(), test::context)); @@ -791,7 +793,7 @@ BOOST_AUTO_TEST_CASE(query_archive__set_block_txs__get_block__expected) //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE_EQUAL(store.create(events_handler)); //// //// // Assemble block. //// BOOST_REQUIRE(query.set(test::genesis.header(), test::context)); @@ -810,7 +812,7 @@ BOOST_AUTO_TEST_CASE(query_archive__populate__null_prevouts__true) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context)); BOOST_REQUIRE(query.set(test::block2, test::context)); @@ -843,7 +845,7 @@ BOOST_AUTO_TEST_CASE(query_archive__populate__partial_prevouts__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(!query.set_link(test::block1a, test::context).is_terminal()); BOOST_REQUIRE(!query.set_link(test::block2a, test::context).is_terminal()); @@ -875,7 +877,7 @@ BOOST_AUTO_TEST_CASE(query_archive__is_coinbase__coinbase__true) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{})); BOOST_REQUIRE(query.set(test::block2, context{})); @@ -892,7 +894,7 @@ BOOST_AUTO_TEST_CASE(query_archive__is_coinbase__non_coinbase__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{})); BOOST_REQUIRE(query.set(test::block2a, context{})); @@ -910,7 +912,7 @@ BOOST_AUTO_TEST_CASE(query_archive__is_malleable__non_malleable__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{})); BOOST_REQUIRE(query.set(test::block2a, context{})); @@ -946,7 +948,7 @@ BOOST_AUTO_TEST_CASE(query_archive__is_malleable__malleable__true) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); // Store 4 blocks. BOOST_REQUIRE(query.initialize(test::genesis)); @@ -1079,7 +1081,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_header__invalid_parent__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); store.header_head() = expected_header_head; store.header_body() = expected_header_body; @@ -1131,7 +1133,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_header__default__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); store.header_head() = expected_header_head; store.header_body() = expected_header_body; @@ -1149,9 +1151,9 @@ BOOST_AUTO_TEST_CASE(query_archive__get_tx_keys__not_found__empty) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.get_tx_keys(query.to_header(system::null_hash)).empty()); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); } BOOST_AUTO_TEST_CASE(query_archive__get_header_key__always__expected) @@ -1160,7 +1162,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_header_key__always__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_header_key(0), test::genesis.hash()); BOOST_REQUIRE_EQUAL(query.get_header_key(1), system::null_hash); @@ -1172,7 +1174,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_point_key__always__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_point_key(0), system::null_hash); @@ -1195,7 +1197,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_tx_key__always__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE_EQUAL(query.get_tx_key(0), test::genesis.transactions_ptr()->front()->hash(false)); BOOST_REQUIRE_EQUAL(query.get_tx_key(1), system::null_hash); @@ -1212,7 +1214,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_height__always__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, context{ 0, 1, 0 })); BOOST_REQUIRE(query.set(test::block2, context{ 0, 2, 0 })); @@ -1242,7 +1244,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_tx_height__not_strong__false) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::tx4)); @@ -1256,7 +1258,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_tx_position__confirmed__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 })); BOOST_REQUIRE(query.set(test::block2a, context{ 0, 2, 0 })); @@ -1297,7 +1299,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_tx_position__always__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, context{ 0, 1, 0 })); BOOST_REQUIRE(query.set(test::block2a, context{ 0, 2, 0 })); @@ -1341,9 +1343,9 @@ BOOST_AUTO_TEST_CASE(query_archive__get_input__not_found__nullptr) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(!query.get_input(query.to_tx(system::null_hash), 0u)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); } BOOST_AUTO_TEST_CASE(query_archive__get_input__genesis__expected) @@ -1356,7 +1358,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_input__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.set(test::genesis, test::context)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -1371,7 +1373,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_inputs__tx_not_found__nullptr) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(!query.get_inputs(1)); } @@ -1382,7 +1384,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_inputs__found__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::tx4)); BOOST_REQUIRE_EQUAL(query.get_inputs(1)->size(), 2u); @@ -1394,11 +1396,11 @@ BOOST_AUTO_TEST_CASE(query_archive__get_output__not_found__nullptr) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(!query.get_output(query.to_tx(system::null_hash), 0u)); BOOST_REQUIRE(!query.get_output({ system::null_hash, 0u })); BOOST_REQUIRE(!query.get_output(0)); - BOOST_REQUIRE_EQUAL(store.close(events_handler), error::success); + BOOST_REQUIRE(!store.close(events_handler)); } BOOST_AUTO_TEST_CASE(query_archive__get_output__genesis__expected) @@ -1411,7 +1413,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_output__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.set(test::genesis, test::context)); const auto tx = test::genesis.transactions_ptr()->front(); @@ -1427,7 +1429,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_outputs__tx_not_found__nullptr) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(!query.get_outputs(1)); } @@ -1438,7 +1440,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_outputs__found__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::tx4)); BOOST_REQUIRE_EQUAL(query.get_outputs(1)->size(), 1u); @@ -1450,7 +1452,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_transactions__tx_not_found__nullptr) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::tx4)); BOOST_REQUIRE(!query.get_transactions(3)); @@ -1462,7 +1464,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_transactions__found__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, test::context)); BOOST_REQUIRE(query.set(test::block2a, test::context)); @@ -1478,7 +1480,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_point__null_point__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1a, test::context)); BOOST_REQUIRE(query.set(test::block2a, test::context)); @@ -1499,7 +1501,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_spenders__unspent_or_not_found__expected settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); BOOST_REQUIRE(query.set(test::block1, test::context)); BOOST_REQUIRE(query.set(test::block2, test::context)); @@ -1537,7 +1539,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_spenders__unspent_or_not_found__expected //// settings.path = TEST_DIRECTORY; //// test::chunk_store store{ settings }; //// test::query_accessor query{ store }; -//// BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); +//// BOOST_REQUIRE(!store.create(events_handler)); //// BOOST_REQUIRE(query.initialize(test::genesis)); //// //// // Neither of the two block1a outputs spent yet. @@ -1593,7 +1595,7 @@ BOOST_AUTO_TEST_CASE(query_archive__get_value__genesis__expected) settings.path = TEST_DIRECTORY; test::chunk_store store{ settings }; test::query_accessor query{ store }; - BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success); + BOOST_REQUIRE(!store.create(events_handler)); BOOST_REQUIRE(query.initialize(test::genesis)); uint64_t value{};