From d8680941b333e869ad492b29ba921ee9a54ffee6 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 4 May 2024 12:04:36 -0400 Subject: [PATCH 1/4] Disable deprecated table settings. --- include/bitcoin/database/settings.hpp | 22 +++++++++++----------- src/settings.cpp | 24 ++++++++++++------------ test/settings.cpp | 18 +++++++++--------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/bitcoin/database/settings.hpp b/include/bitcoin/database/settings.hpp index 36f1a630..ac58c3e9 100644 --- a/include/bitcoin/database/settings.hpp +++ b/include/bitcoin/database/settings.hpp @@ -91,17 +91,6 @@ struct BCD_API settings /// Caches. /// ----------------------------------------------------------------------- - uint32_t bootstrap_size; - uint16_t bootstrap_rate; - - uint32_t buffer_buckets; - uint64_t buffer_size; - uint16_t buffer_rate; - - uint32_t neutrino_buckets; - uint64_t neutrino_size; - uint16_t neutrino_rate; - uint32_t validated_bk_buckets; uint64_t validated_bk_size; uint16_t validated_bk_rate; @@ -109,6 +98,17 @@ struct BCD_API settings uint32_t validated_tx_buckets; uint64_t validated_tx_size; uint16_t validated_tx_rate; + + uint32_t neutrino_buckets; + uint64_t neutrino_size; + uint16_t neutrino_rate; + + ////uint32_t bootstrap_size; + ////uint16_t bootstrap_rate; + + ////uint32_t buffer_buckets; + ////uint64_t buffer_size; + ////uint16_t buffer_rate; }; } // namespace database diff --git a/src/settings.cpp b/src/settings.cpp index 791ee80c..bb6cde2f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -78,24 +78,24 @@ settings::settings() NOEXCEPT // Caches. - bootstrap_size{ 1 }, - bootstrap_rate{ 50 }, - - buffer_buckets{ 100 }, - buffer_size{ 1 }, - buffer_rate{ 50 }, - - neutrino_buckets{ 100 }, - neutrino_size{ 1 }, - neutrino_rate{ 50 }, - validated_bk_buckets{ 100 }, validated_bk_size{ 1 }, validated_bk_rate{ 50 }, validated_tx_buckets{ 100 }, validated_tx_size{ 1 }, - validated_tx_rate{ 50 } + validated_tx_rate{ 50 }, + + neutrino_buckets{ 100 }, + neutrino_size{ 1 }, + neutrino_rate{ 50 } + + ////bootstrap_size{ 1 }, + ////bootstrap_rate{ 50 }, + + ////buffer_buckets{ 100 }, + ////buffer_size{ 1 }, + ////buffer_rate{ 50 } { } diff --git a/test/settings.cpp b/test/settings.cpp index 3062e59c..49b49e8c 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -23,9 +23,9 @@ BOOST_AUTO_TEST_SUITE(settings_tests) BOOST_AUTO_TEST_CASE(settings__construct__default__expected) { database::settings configuration; + BOOST_REQUIRE_EQUAL(configuration.path, "bitcoin"); // Archives. - BOOST_REQUIRE_EQUAL(configuration.path, "bitcoin"); BOOST_REQUIRE_EQUAL(configuration.header_buckets, 100u); BOOST_REQUIRE_EQUAL(configuration.header_size, 1u); BOOST_REQUIRE_EQUAL(configuration.header_rate, 50u); @@ -61,20 +61,20 @@ BOOST_AUTO_TEST_CASE(settings__construct__default__expected) BOOST_REQUIRE_EQUAL(configuration.strong_tx_rate, 50u); // Caches. - BOOST_REQUIRE_EQUAL(configuration.bootstrap_size, 1u); - BOOST_REQUIRE_EQUAL(configuration.bootstrap_rate, 50u); - BOOST_REQUIRE_EQUAL(configuration.buffer_buckets, 100u); - BOOST_REQUIRE_EQUAL(configuration.buffer_size, 1u); - BOOST_REQUIRE_EQUAL(configuration.buffer_rate, 50u); - BOOST_REQUIRE_EQUAL(configuration.neutrino_buckets, 100u); - BOOST_REQUIRE_EQUAL(configuration.neutrino_size, 1u); - BOOST_REQUIRE_EQUAL(configuration.neutrino_rate, 50u); BOOST_REQUIRE_EQUAL(configuration.validated_bk_buckets, 100u); BOOST_REQUIRE_EQUAL(configuration.validated_bk_size, 1u); BOOST_REQUIRE_EQUAL(configuration.validated_bk_rate, 50u); BOOST_REQUIRE_EQUAL(configuration.validated_tx_buckets, 100u); BOOST_REQUIRE_EQUAL(configuration.validated_tx_size, 1u); BOOST_REQUIRE_EQUAL(configuration.validated_tx_rate, 50u); + BOOST_REQUIRE_EQUAL(configuration.neutrino_buckets, 100u); + BOOST_REQUIRE_EQUAL(configuration.neutrino_size, 1u); + BOOST_REQUIRE_EQUAL(configuration.neutrino_rate, 50u); + ////BOOST_REQUIRE_EQUAL(configuration.bootstrap_size, 1u); + ////BOOST_REQUIRE_EQUAL(configuration.bootstrap_rate, 50u); + ////BOOST_REQUIRE_EQUAL(configuration.buffer_buckets, 100u); + ////BOOST_REQUIRE_EQUAL(configuration.buffer_size, 1u); + ////BOOST_REQUIRE_EQUAL(configuration.buffer_rate, 50u); } BOOST_AUTO_TEST_SUITE_END() From 667e24a1c44eff0c3e40c5819917d0fe87a783b8 Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 4 May 2024 14:17:00 -0400 Subject: [PATCH 2/4] Rename spend table file to archive-spend. --- include/bitcoin/database/impl/store.ipp | 6 +++--- include/bitcoin/database/tables/schema.hpp | 2 +- test/store.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index 25629d5b..9a8503d2 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -88,8 +88,8 @@ CLASS::store(const settings& config) NOEXCEPT confirmed_body_(body(config.path, schema::indexes::confirmed), config.confirmed_size, config.confirmed_rate), confirmed(confirmed_head_, confirmed_body_), - spend_head_(head(config.path / schema::dir::heads, schema::indexes::spend)), - spend_body_(body(config.path, schema::indexes::spend), config.spend_size, config.spend_rate), + spend_head_(head(config.path / schema::dir::heads, schema::archive::spend)), + spend_body_(body(config.path, schema::archive::spend), config.spend_size, config.spend_rate), spend(spend_head_, spend_body_, std::max(config.spend_buckets, nonzero)), strong_tx_head_(head(config.path / schema::dir::heads, schema::indexes::strong_tx)), @@ -781,7 +781,7 @@ code CLASS::dump(const path& folder, return error::dump_file; if (!dump(confirmed_buffer, schema::indexes::confirmed, table_t::confirmed_head)) return error::dump_file; - if (!dump(spend_buffer, schema::indexes::spend, table_t::spend_head)) + if (!dump(spend_buffer, schema::archive::spend, table_t::spend_head)) return error::dump_file; if (!dump(strong_tx_buffer, schema::indexes::strong_tx, table_t::strong_tx_head)) return error::dump_file; diff --git a/include/bitcoin/database/tables/schema.hpp b/include/bitcoin/database/tables/schema.hpp index 619addcb..c09b44b9 100644 --- a/include/bitcoin/database/tables/schema.hpp +++ b/include/bitcoin/database/tables/schema.hpp @@ -47,6 +47,7 @@ namespace schema constexpr auto point = "archive_point"; constexpr auto input = "archive_input"; constexpr auto output = "archive_output"; + constexpr auto spend = "archive_spend"; constexpr auto puts = "archive_puts"; constexpr auto txs = "archive_txs"; constexpr auto tx = "archive_tx"; @@ -57,7 +58,6 @@ namespace schema constexpr auto address = "address"; constexpr auto candidate = "candidate"; constexpr auto confirmed = "confirmed"; - constexpr auto spend = "spend"; constexpr auto strong_tx = "strong_tx"; } diff --git a/test/store.cpp b/test/store.cpp index f57cee3f..70f947cd 100644 --- a/test/store.cpp +++ b/test/store.cpp @@ -90,8 +90,8 @@ BOOST_AUTO_TEST_CASE(store__paths__default_configuration__expected) BOOST_REQUIRE_EQUAL(instance.candidate_body_file(), "bitcoin/candidate.data"); BOOST_REQUIRE_EQUAL(instance.confirmed_head_file(), "bitcoin/heads/confirmed.head"); BOOST_REQUIRE_EQUAL(instance.confirmed_body_file(), "bitcoin/confirmed.data"); - BOOST_REQUIRE_EQUAL(instance.spend_head_file(), "bitcoin/heads/spend.head"); - BOOST_REQUIRE_EQUAL(instance.spend_body_file(), "bitcoin/spend.data"); + BOOST_REQUIRE_EQUAL(instance.spend_head_file(), "bitcoin/heads/archive_spend.head"); + BOOST_REQUIRE_EQUAL(instance.spend_body_file(), "bitcoin/archive_spend.data"); BOOST_REQUIRE_EQUAL(instance.strong_tx_head_file(), "bitcoin/heads/strong_tx.head"); BOOST_REQUIRE_EQUAL(instance.strong_tx_body_file(), "bitcoin/strong_tx.data"); From 2b04e80786545f27e4367b595db1789a8334908d Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 4 May 2024 17:45:53 -0400 Subject: [PATCH 3/4] Comment. --- include/bitcoin/database/error.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/bitcoin/database/error.hpp b/include/bitcoin/database/error.hpp index c2646ed3..e86dcc5c 100644 --- a/include/bitcoin/database/error.hpp +++ b/include/bitcoin/database/error.hpp @@ -86,8 +86,6 @@ enum error_t : uint8_t restore_table, verify_table, - /// states - /// tx fully valid in the given header context. tx_connected, From 69cb3267d543eba68fbadd539c1f327c1cf5230b Mon Sep 17 00:00:00 2001 From: evoskuil Date: Sat, 4 May 2024 18:05:45 -0400 Subject: [PATCH 4/4] Reorganize table code and related schema namespaces. --- Makefile.am | 13 +- .../libbitcoin-database.vcxproj | 10 +- .../libbitcoin-database.vcxproj.filters | 35 ++-- include/bitcoin/database.hpp | 10 +- include/bitcoin/database/impl/store.ipp | 190 ++++++++++-------- include/bitcoin/database/settings.hpp | 27 +-- include/bitcoin/database/store.hpp | 35 ++-- .../database/tables/archives/input.hpp | 2 +- .../tables/{indexes => archives}/spend.hpp | 4 +- .../tables/{indexes => optionals}/address.hpp | 4 +- .../{caches => optionals}/bootstrap.hpp | 4 +- .../tables/{caches => optionals}/buffer.hpp | 4 +- .../tables/{caches => optionals}/neutrino.hpp | 4 +- include/bitcoin/database/tables/schema.hpp | 22 +- include/bitcoin/database/tables/table.hpp | 41 ++-- include/bitcoin/database/tables/tables.hpp | 11 +- src/settings.cpp | 28 +-- 17 files changed, 244 insertions(+), 200 deletions(-) rename include/bitcoin/database/tables/{indexes => archives}/spend.hpp (98%) rename include/bitcoin/database/tables/{indexes => optionals}/address.hpp (94%) rename include/bitcoin/database/tables/{caches => optionals}/bootstrap.hpp (96%) rename include/bitcoin/database/tables/{caches => optionals}/buffer.hpp (96%) rename include/bitcoin/database/tables/{caches => optionals}/neutrino.hpp (97%) diff --git a/Makefile.am b/Makefile.am index 1cfe5fb5..ce66c7e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -222,24 +222,27 @@ include_bitcoin_database_tables_archives_HEADERS = \ include/bitcoin/database/tables/archives/output.hpp \ include/bitcoin/database/tables/archives/point.hpp \ include/bitcoin/database/tables/archives/puts.hpp \ + include/bitcoin/database/tables/archives/spend.hpp \ include/bitcoin/database/tables/archives/transaction.hpp \ include/bitcoin/database/tables/archives/txs.hpp include_bitcoin_database_tables_cachesdir = ${includedir}/bitcoin/database/tables/caches include_bitcoin_database_tables_caches_HEADERS = \ - include/bitcoin/database/tables/caches/bootstrap.hpp \ - include/bitcoin/database/tables/caches/buffer.hpp \ - include/bitcoin/database/tables/caches/neutrino.hpp \ include/bitcoin/database/tables/caches/validated_bk.hpp \ include/bitcoin/database/tables/caches/validated_tx.hpp include_bitcoin_database_tables_indexesdir = ${includedir}/bitcoin/database/tables/indexes include_bitcoin_database_tables_indexes_HEADERS = \ - include/bitcoin/database/tables/indexes/address.hpp \ include/bitcoin/database/tables/indexes/height.hpp \ - include/bitcoin/database/tables/indexes/spend.hpp \ include/bitcoin/database/tables/indexes/strong_tx.hpp +include_bitcoin_database_tables_optionalsdir = ${includedir}/bitcoin/database/tables/optionals +include_bitcoin_database_tables_optionals_HEADERS = \ + include/bitcoin/database/tables/optionals/address.hpp \ + include/bitcoin/database/tables/optionals/bootstrap.hpp \ + include/bitcoin/database/tables/optionals/buffer.hpp \ + include/bitcoin/database/tables/optionals/neutrino.hpp + # Custom make targets. #============================================================================== diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj index 02715535..1d9cb6e7 100644 --- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj @@ -122,19 +122,19 @@ + - - - - - + + + + diff --git a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters index 2df83fe8..7ce4d3ef 100644 --- a/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-database/libbitcoin-database.vcxproj.filters @@ -55,9 +55,12 @@ {62D7FBEE-4D52-424A-0000-000000000005} - + {62D7FBEE-4D52-424A-0000-000000000006} + + {62D7FBEE-4D52-424A-0000-000000000007} + {62D7FBEE-4D52-424A-0000-000000000000} @@ -218,21 +221,15 @@ include\bitcoin\database\tables\archives + + include\bitcoin\database\tables\archives + include\bitcoin\database\tables\archives include\bitcoin\database\tables\archives - - include\bitcoin\database\tables\caches - - - include\bitcoin\database\tables\caches - - - include\bitcoin\database\tables\caches - include\bitcoin\database\tables\caches @@ -245,18 +242,24 @@ include\bitcoin\database\tables - - include\bitcoin\database\tables\indexes - include\bitcoin\database\tables\indexes - - include\bitcoin\database\tables\indexes - include\bitcoin\database\tables\indexes + + include\bitcoin\database\tables\optionals + + + include\bitcoin\database\tables\optionals + + + include\bitcoin\database\tables\optionals + + + include\bitcoin\database\tables\optionals + include\bitcoin\database\tables diff --git a/include/bitcoin/database.hpp b/include/bitcoin/database.hpp index 07fc73f0..4b2f2f75 100644 --- a/include/bitcoin/database.hpp +++ b/include/bitcoin/database.hpp @@ -58,16 +58,16 @@ #include #include #include +#include #include #include -#include -#include -#include #include #include -#include #include -#include #include +#include +#include +#include +#include #endif diff --git a/include/bitcoin/database/impl/store.ipp b/include/bitcoin/database/impl/store.ipp index 9a8503d2..0f0f47f5 100644 --- a/include/bitcoin/database/impl/store.ipp +++ b/include/bitcoin/database/impl/store.ipp @@ -50,10 +50,6 @@ CLASS::store(const settings& config) NOEXCEPT header_body_(body(config.path, schema::archive::header), config.header_size, config.header_rate), header(header_head_, header_body_, std::max(config.header_buckets, nonzero)), - point_head_(head(config.path / schema::dir::heads, schema::archive::point)), - point_body_(body(config.path, schema::archive::point), config.point_size, config.point_rate), - point(point_head_, point_body_, std::max(config.point_buckets, nonzero)), - input_head_(head(config.path / schema::dir::heads, schema::archive::input)), input_body_(body(config.path, schema::archive::input), config.input_size, config.input_rate), input(input_head_, input_body_), @@ -62,10 +58,18 @@ CLASS::store(const settings& config) NOEXCEPT output_body_(body(config.path, schema::archive::output), config.output_size, config.output_rate), output(output_head_, output_body_), + point_head_(head(config.path / schema::dir::heads, schema::archive::point)), + point_body_(body(config.path, schema::archive::point), config.point_size, config.point_rate), + point(point_head_, point_body_, std::max(config.point_buckets, nonzero)), + puts_head_(head(config.path / schema::dir::heads, schema::archive::puts)), puts_body_(body(config.path, schema::archive::puts), config.puts_size, config.puts_rate), puts(puts_head_, puts_body_), + spend_head_(head(config.path / schema::dir::heads, schema::archive::spend)), + spend_body_(body(config.path, schema::archive::spend), config.spend_size, config.spend_rate), + spend(spend_head_, spend_body_, std::max(config.spend_buckets, nonzero)), + tx_head_(head(config.path / schema::dir::heads, schema::archive::tx)), tx_body_(body(config.path, schema::archive::tx), config.tx_size, config.tx_rate), tx(tx_head_, tx_body_, std::max(config.tx_buckets, nonzero)), @@ -76,10 +80,6 @@ CLASS::store(const settings& config) NOEXCEPT // Indexes. - address_head_(head(config.path / schema::dir::heads, schema::indexes::address)), - address_body_(body(config.path, schema::indexes::address), config.address_size, config.address_rate), - address(address_head_, address_body_, std::max(config.address_buckets, nonzero)), - candidate_head_(head(config.path / schema::dir::heads, schema::indexes::candidate)), candidate_body_(body(config.path, schema::indexes::candidate), config.candidate_size, config.candidate_rate), candidate(candidate_head_, candidate_body_), @@ -88,10 +88,6 @@ CLASS::store(const settings& config) NOEXCEPT confirmed_body_(body(config.path, schema::indexes::confirmed), config.confirmed_size, config.confirmed_rate), confirmed(confirmed_head_, confirmed_body_), - spend_head_(head(config.path / schema::dir::heads, schema::archive::spend)), - spend_body_(body(config.path, schema::archive::spend), config.spend_size, config.spend_rate), - spend(spend_head_, spend_body_, std::max(config.spend_buckets, nonzero)), - strong_tx_head_(head(config.path / schema::dir::heads, schema::indexes::strong_tx)), strong_tx_body_(body(config.path, schema::indexes::strong_tx), config.strong_tx_size, config.strong_tx_rate), strong_tx(strong_tx_head_, strong_tx_body_, std::max(config.strong_tx_buckets, nonzero)), @@ -106,16 +102,22 @@ CLASS::store(const settings& config) NOEXCEPT validated_tx_body_(body(config.path, schema::caches::validated_tx), config.validated_tx_size, config.validated_tx_rate), validated_tx(validated_tx_head_, validated_tx_body_, std::max(config.validated_tx_buckets, nonzero)), - neutrino_head_(head(config.path / schema::dir::heads, schema::caches::neutrino)), - neutrino_body_(body(config.path, schema::caches::neutrino), config.neutrino_size, config.neutrino_rate), + // Optionals. + + address_head_(head(config.path / schema::dir::heads, schema::optionals::address)), + address_body_(body(config.path, schema::optionals::address), config.address_size, config.address_rate), + address(address_head_, address_body_, std::max(config.address_buckets, nonzero)), + + neutrino_head_(head(config.path / schema::dir::heads, schema::optionals::neutrino)), + neutrino_body_(body(config.path, schema::optionals::neutrino), config.neutrino_size, config.neutrino_rate), neutrino(neutrino_head_, neutrino_body_, std::max(config.neutrino_buckets, nonzero)), - ////bootstrap_head_(head(config.path / schema::dir::heads, schema::caches::bootstrap)), - ////bootstrap_body_(body(config.path, schema::caches::bootstrap), config.bootstrap_size, config.bootstrap_rate), + ////bootstrap_head_(head(config.path / schema::dir::heads, schema::optionals::bootstrap)), + ////bootstrap_body_(body(config.path, schema::optionals::bootstrap), config.bootstrap_size, config.bootstrap_rate), ////bootstrap(bootstrap_head_, bootstrap_body_), - ////buffer_head_(head(config.path / schema::dir::heads, schema::caches::buffer)), - ////buffer_body_(body(config.path, schema::caches::buffer), config.buffer_size, config.buffer_rate), + ////buffer_head_(head(config.path / schema::dir::heads, schema::optionals::buffer)), + ////buffer_body_(body(config.path, schema::optionals::buffer), config.buffer_size, config.buffer_rate), ////buffer(buffer_head_, buffer_body_, std::max(config.buffer_buckets, nonzero)), // Locks. @@ -156,27 +158,25 @@ code CLASS::create(const event_handler& handler) NOEXCEPT else if (!create(header_head_, table_t::header_head)) ec = error::create_file; else if (!create(header_body_, table_t::header_body)) ec = error::create_file; - else if (!create(point_head_, table_t::point_head)) ec = error::create_file; - else if (!create(point_body_, table_t::point_body)) ec = error::create_file; else if (!create(input_head_, table_t::input_head)) ec = error::create_file; else if (!create(input_body_, table_t::input_body)) ec = error::create_file; else if (!create(output_head_, table_t::output_head)) ec = error::create_file; else if (!create(output_body_, table_t::output_body)) ec = error::create_file; + else if (!create(point_head_, table_t::point_head)) ec = error::create_file; + else if (!create(point_body_, table_t::point_body)) ec = error::create_file; else if (!create(puts_head_, table_t::puts_head)) ec = error::create_file; else if (!create(puts_body_, table_t::puts_body)) ec = error::create_file; + else if (!create(spend_head_, table_t::spend_head)) ec = error::create_file; + else if (!create(spend_body_, table_t::spend_body)) ec = error::create_file; else if (!create(tx_head_, table_t::tx_head)) ec = error::create_file; else if (!create(tx_body_, table_t::tx_body)) ec = error::create_file; else if (!create(txs_head_, table_t::txs_head)) ec = error::create_file; else if (!create(txs_body_, table_t::txs_body)) ec = error::create_file; - else if (!create(address_head_, table_t::address_head)) ec = error::create_file; - else if (!create(address_body_, table_t::address_body)) ec = error::create_file; else if (!create(candidate_head_, table_t::candidate_head)) ec = error::create_file; else if (!create(candidate_body_, table_t::candidate_body)) ec = error::create_file; else if (!create(confirmed_head_, table_t::confirmed_head)) ec = error::create_file; else if (!create(confirmed_body_, table_t::confirmed_body)) ec = error::create_file; - else if (!create(spend_head_, table_t::spend_head)) ec = error::create_file; - else if (!create(spend_body_, table_t::spend_body)) ec = error::create_file; else if (!create(strong_tx_head_, table_t::strong_tx_head)) ec = error::create_file; else if (!create(strong_tx_body_, table_t::strong_tx_body)) ec = error::create_file; @@ -184,6 +184,9 @@ code CLASS::create(const event_handler& handler) NOEXCEPT else if (!create(validated_bk_body_, table_t::validated_bk_body)) ec = error::create_file; else if (!create(validated_tx_head_, table_t::validated_tx_head)) ec = error::create_file; else if (!create(validated_tx_body_, table_t::validated_tx_body)) ec = error::create_file; + + else if (!create(address_head_, table_t::address_head)) ec = error::create_file; + else if (!create(address_body_, table_t::address_body)) ec = error::create_file; else if (!create(neutrino_head_, table_t::neutrino_head)) ec = error::create_file; else if (!create(neutrino_body_, table_t::neutrino_body)) ec = error::create_file; ////else if (!create(bootstrap_head_, table_t::bootstrap_head)) ec = error::create_file; @@ -203,21 +206,22 @@ code CLASS::create(const event_handler& handler) NOEXCEPT // Populate /heads files and truncate body sizes to zero. if (!populate(header, table_t::header_table)) ec = error::create_table; - else if (!populate(point, table_t::point_table)) ec = error::create_table; else if (!populate(input, table_t::input_table)) ec = error::create_table; else if (!populate(output, table_t::output_table)) ec = error::create_table; + else if (!populate(point, table_t::point_table)) ec = error::create_table; else if (!populate(puts, table_t::puts_table)) ec = error::create_table; + else if (!populate(spend, table_t::spend_table)) ec = error::create_table; else if (!populate(tx, table_t::tx_table)) ec = error::create_table; else if (!populate(txs, table_t::txs_table)) ec = error::create_table; - else if (!populate(address, table_t::address_table)) ec = error::create_table; else if (!populate(candidate, table_t::candidate_table)) ec = error::create_table; else if (!populate(confirmed, table_t::confirmed_table)) ec = error::create_table; - else if (!populate(spend, table_t::spend_table)) ec = error::create_table; else if (!populate(strong_tx, table_t::strong_tx_table)) ec = error::create_table; else if (!populate(validated_bk, table_t::validated_bk_table)) ec = error::create_table; else if (!populate(validated_tx, table_t::validated_tx_table)) ec = error::create_table; + + else if (!populate(address, table_t::address_table)) ec = error::create_table; else if (!populate(neutrino, table_t::neutrino_table)) ec = error::create_table; ////else if (!populate(bootstrap, table_t::bootstrap_table)) ec = error::create_table; ////else if (!populate(buffer, table_t::buffer_table)) ec = error::create_table; @@ -263,21 +267,22 @@ code CLASS::open(const event_handler& handler) NOEXCEPT }; if (!verify(header, table_t::header_table)) ec = error::verify_table; - else if (!verify(point, table_t::point_table)) ec = error::verify_table; else if (!verify(input, table_t::input_table)) ec = error::verify_table; else if (!verify(output, table_t::output_table)) ec = error::verify_table; + else if (!verify(point, table_t::point_table)) ec = error::verify_table; else if (!verify(puts, table_t::puts_table)) ec = error::verify_table; + else if (!verify(spend, table_t::spend_table)) ec = error::verify_table; else if (!verify(tx, table_t::tx_table)) ec = error::verify_table; else if (!verify(txs, table_t::txs_table)) ec = error::verify_table; - else if (!verify(address, table_t::address_table)) ec = error::verify_table; else if (!verify(candidate, table_t::candidate_table)) ec = error::verify_table; else if (!verify(confirmed, table_t::confirmed_table)) ec = error::verify_table; - else if (!verify(spend, table_t::spend_table)) ec = error::verify_table; else if (!verify(strong_tx, table_t::strong_tx_table)) ec = error::verify_table; else if (!verify(validated_bk, table_t::validated_bk_table)) ec = error::verify_table; else if (!verify(validated_tx, table_t::validated_tx_table)) ec = error::verify_table; + + else if (!verify(address, table_t::address_table)) ec = error::verify_table; else if (!verify(neutrino, table_t::neutrino_table)) ec = error::verify_table; ////else if (!verify(bootstrap, table_t::bootstrap_table)) ec = error::verify_table; ////else if (!verify(buffer, table_t::buffer_table)) ec = error::verify_table; @@ -320,21 +325,22 @@ code CLASS::snapshot(const event_handler& handler) NOEXCEPT // Assumes/requires tables open/loaded. flush(ec, header_body_, table_t::header_body); - flush(ec, point_body_, table_t::point_body); flush(ec, input_body_, table_t::input_body); flush(ec, output_body_, table_t::output_body); + flush(ec, point_body_, table_t::point_body); flush(ec, puts_body_, table_t::puts_body); + flush(ec, spend_body_, table_t::spend_body); flush(ec, tx_body_, table_t::tx_body); flush(ec, txs_body_, table_t::txs_body); - flush(ec, address_body_, table_t::address_body); flush(ec, candidate_body_, table_t::candidate_body); flush(ec, confirmed_body_, table_t::confirmed_body); - flush(ec, spend_body_, table_t::spend_body); flush(ec, strong_tx_body_, table_t::strong_tx_body); flush(ec, validated_bk_body_, table_t::validated_bk_body); flush(ec, validated_tx_body_, table_t::validated_tx_body); + + flush(ec, address_body_, table_t::address_body); flush(ec, neutrino_body_, table_t::neutrino_body); ////flush(ec, bootstrap_body_, table_t::bootstrap_body); ////flush(ec, buffer_body_, table_t::buffer_body); @@ -364,21 +370,22 @@ code CLASS::close(const event_handler& handler) NOEXCEPT }; if (!close(header, table_t::header_table)) ec = error::close_table; - else if (!close(point, table_t::point_table)) ec = error::close_table; else if (!close(input, table_t::input_table)) ec = error::close_table; else if (!close(output, table_t::output_table)) ec = error::close_table; + else if (!close(point, table_t::point_table)) ec = error::close_table; else if (!close(puts, table_t::puts_table)) ec = error::close_table; + else if (!close(spend, table_t::spend_table)) ec = error::close_table; else if (!close(tx, table_t::tx_table)) ec = error::close_table; else if (!close(txs, table_t::txs_table)) ec = error::close_table; - else if (!close(address, table_t::address_table)) ec = error::close_table; else if (!close(candidate, table_t::candidate_table)) ec = error::close_table; else if (!close(confirmed, table_t::confirmed_table)) ec = error::close_table; - else if (!close(spend, table_t::spend_table)) ec = error::close_table; else if (!close(strong_tx, table_t::strong_tx_table)) ec = error::close_table; else if (!close(validated_bk, table_t::validated_bk_table)) ec = error::close_table; else if (!close(validated_tx, table_t::validated_tx_table)) ec = error::close_table; + + else if (!close(address, table_t::address_table)) ec = error::close_table; else if (!close(neutrino, table_t::neutrino_table)) ec = error::close_table; ////else if (!close(bootstrap, table_t::bootstrap_table)) ec = error::close_table; ////else if (!close(buffer, table_t::buffer_table)) ec = error::close_table; @@ -414,19 +421,19 @@ bool CLASS::get_error(const code& ec) const NOEXCEPT }; return match(header_body_) - && match(point_body_) && match(input_body_) && match(output_body_) + && match(point_body_) && match(puts_body_) + && match(spend_body_) && match(tx_body_) && match(txs_body_) - && match(address_body_) && match(candidate_body_) && match(confirmed_body_) - && match(spend_body_) && match(strong_tx_body_) && match(validated_bk_body_) && match(validated_tx_body_) + && match(address_body_) && match(neutrino_body_) ////&& match(bootstrap_body_) ////&& match(buffer_body_) @@ -437,19 +444,19 @@ TEMPLATE void CLASS::clear_error() NOEXCEPT { header_body_.clear_error(); - point_body_.clear_error(); input_body_.clear_error(); output_body_.clear_error(); + point_body_.clear_error(); puts_body_.clear_error(); + spend_body_.clear_error(); tx_body_.clear_error(); txs_body_.clear_error(); - address_body_.clear_error(); candidate_body_.clear_error(); confirmed_body_.clear_error(); - spend_body_.clear_error(); strong_tx_body_.clear_error(); validated_bk_body_.clear_error(); validated_tx_body_.clear_error(); + address_body_.clear_error(); neutrino_body_.clear_error(); ////bootstrap_body_.clear_error(); ////buffer_body_.clear_error(); @@ -473,27 +480,25 @@ code CLASS::open_load(const event_handler& handler) NOEXCEPT open(ec, header_head_, table_t::header_head); open(ec, header_body_, table_t::header_body); - open(ec, point_head_, table_t::point_head); - open(ec, point_body_, table_t::point_body); open(ec, input_head_, table_t::input_head); open(ec, input_body_, table_t::input_body); open(ec, output_head_, table_t::output_head); open(ec, output_body_, table_t::output_body); + open(ec, point_head_, table_t::point_head); + open(ec, point_body_, table_t::point_body); open(ec, puts_head_, table_t::puts_head); open(ec, puts_body_, table_t::puts_body); + open(ec, spend_head_, table_t::spend_head); + open(ec, spend_body_, table_t::spend_body); open(ec, tx_head_, table_t::tx_head); open(ec, tx_body_, table_t::tx_body); open(ec, txs_head_, table_t::txs_head); open(ec, txs_body_, table_t::txs_body); - open(ec, address_head_, table_t::address_head); - open(ec, address_body_, table_t::address_body); open(ec, candidate_head_, table_t::candidate_head); open(ec, candidate_body_, table_t::candidate_body); open(ec, confirmed_head_, table_t::confirmed_head); open(ec, confirmed_body_, table_t::confirmed_body); - open(ec, spend_head_, table_t::spend_head); - open(ec, spend_body_, table_t::spend_body); open(ec, strong_tx_head_, table_t::strong_tx_head); open(ec, strong_tx_body_, table_t::strong_tx_body); @@ -501,6 +506,9 @@ code CLASS::open_load(const event_handler& handler) NOEXCEPT open(ec, validated_bk_body_, table_t::validated_bk_body); open(ec, validated_tx_head_, table_t::validated_tx_head); open(ec, validated_tx_body_, table_t::validated_tx_body); + + open(ec, address_head_, table_t::address_head); + open(ec, address_body_, table_t::address_body); open(ec, neutrino_head_, table_t::neutrino_head); open(ec, neutrino_body_, table_t::neutrino_body); ////open(ec, bootstrap_head_, table_t::bootstrap_head); @@ -519,27 +527,25 @@ code CLASS::open_load(const event_handler& handler) NOEXCEPT load(ec, header_head_, table_t::header_head); load(ec, header_body_, table_t::header_body); - load(ec, point_head_, table_t::point_head); - load(ec, point_body_, table_t::point_body); load(ec, input_head_, table_t::input_head); load(ec, input_body_, table_t::input_body); load(ec, output_head_, table_t::output_head); load(ec, output_body_, table_t::output_body); + load(ec, point_head_, table_t::point_head); + load(ec, point_body_, table_t::point_body); load(ec, puts_head_, table_t::puts_head); load(ec, puts_body_, table_t::puts_body); + load(ec, spend_head_, table_t::spend_head); + load(ec, spend_body_, table_t::spend_body); load(ec, tx_head_, table_t::tx_head); load(ec, tx_body_, table_t::tx_body); load(ec, txs_head_, table_t::txs_head); load(ec, txs_body_, table_t::txs_body); - load(ec, address_head_, table_t::address_head); - load(ec, address_body_, table_t::address_body); load(ec, candidate_head_, table_t::candidate_head); load(ec, candidate_body_, table_t::candidate_body); load(ec, confirmed_head_, table_t::confirmed_head); load(ec, confirmed_body_, table_t::confirmed_body); - load(ec, spend_head_, table_t::spend_head); - load(ec, spend_body_, table_t::spend_body); load(ec, strong_tx_head_, table_t::strong_tx_head); load(ec, strong_tx_body_, table_t::strong_tx_body); @@ -547,6 +553,9 @@ code CLASS::open_load(const event_handler& handler) NOEXCEPT load(ec, validated_bk_body_, table_t::validated_bk_body); load(ec, validated_tx_head_, table_t::validated_tx_head); load(ec, validated_tx_body_, table_t::validated_tx_body); + + load(ec, address_head_, table_t::address_head); + load(ec, address_body_, table_t::address_body); load(ec, neutrino_head_, table_t::neutrino_head); load(ec, neutrino_body_, table_t::neutrino_body); ////load(ec, bootstrap_head_, table_t::bootstrap_head); @@ -573,27 +582,25 @@ code CLASS::unload_close(const event_handler& handler) NOEXCEPT unload(ec, header_head_, table_t::header_head); unload(ec, header_body_, table_t::header_body); - unload(ec, point_head_, table_t::point_head); - unload(ec, point_body_, table_t::point_body); unload(ec, input_head_, table_t::input_head); unload(ec, input_body_, table_t::input_body); unload(ec, output_head_, table_t::output_head); unload(ec, output_body_, table_t::output_body); + unload(ec, point_head_, table_t::point_head); + unload(ec, point_body_, table_t::point_body); unload(ec, puts_head_, table_t::puts_head); unload(ec, puts_body_, table_t::puts_body); + unload(ec, spend_head_, table_t::spend_head); + unload(ec, spend_body_, table_t::spend_body); unload(ec, tx_head_, table_t::tx_head); unload(ec, tx_body_, table_t::tx_body); unload(ec, txs_head_, table_t::txs_head); unload(ec, txs_body_, table_t::txs_body); - unload(ec, address_head_, table_t::address_head); - unload(ec, address_body_, table_t::address_body); unload(ec, candidate_head_, table_t::candidate_head); unload(ec, candidate_body_, table_t::candidate_body); unload(ec, confirmed_head_, table_t::confirmed_head); unload(ec, confirmed_body_, table_t::confirmed_body); - unload(ec, spend_head_, table_t::spend_head); - unload(ec, spend_body_, table_t::spend_body); unload(ec, strong_tx_head_, table_t::strong_tx_head); unload(ec, strong_tx_body_, table_t::strong_tx_body); @@ -601,6 +608,9 @@ code CLASS::unload_close(const event_handler& handler) NOEXCEPT unload(ec, validated_bk_body_, table_t::validated_bk_body); unload(ec, validated_tx_head_, table_t::validated_tx_head); unload(ec, validated_tx_body_, table_t::validated_tx_body); + + unload(ec, address_head_, table_t::address_head); + unload(ec, address_body_, table_t::address_body); unload(ec, neutrino_head_, table_t::neutrino_head); unload(ec, neutrino_body_, table_t::neutrino_body); ////unload(ec, bootstrap_head_, table_t::bootstrap_head); @@ -619,27 +629,25 @@ code CLASS::unload_close(const event_handler& handler) NOEXCEPT close(ec, header_head_, table_t::header_head); close(ec, header_body_, table_t::header_body); - close(ec, point_head_, table_t::point_head); - close(ec, point_body_, table_t::point_body); close(ec, input_head_, table_t::input_head); close(ec, input_body_, table_t::input_body); close(ec, output_head_, table_t::output_head); close(ec, output_body_, table_t::output_body); + close(ec, point_head_, table_t::point_head); + close(ec, point_body_, table_t::point_body); close(ec, puts_head_, table_t::puts_head); close(ec, puts_body_, table_t::puts_body); + close(ec, spend_head_, table_t::spend_head); + close(ec, spend_body_, table_t::spend_body); close(ec, tx_head_, table_t::tx_head); close(ec, tx_body_, table_t::tx_body); close(ec, txs_head_, table_t::txs_head); close(ec, txs_body_, table_t::txs_body); - close(ec, address_head_, table_t::address_head); - close(ec, address_body_, table_t::address_body); close(ec, candidate_head_, table_t::candidate_head); close(ec, candidate_body_, table_t::candidate_body); close(ec, confirmed_head_, table_t::confirmed_head); close(ec, confirmed_body_, table_t::confirmed_body); - close(ec, spend_head_, table_t::spend_head); - close(ec, spend_body_, table_t::spend_body); close(ec, strong_tx_head_, table_t::strong_tx_head); close(ec, strong_tx_body_, table_t::strong_tx_body); @@ -647,6 +655,9 @@ code CLASS::unload_close(const event_handler& handler) NOEXCEPT close(ec, validated_bk_body_, table_t::validated_bk_body); close(ec, validated_tx_head_, table_t::validated_tx_head); close(ec, validated_tx_body_, table_t::validated_tx_body); + + close(ec, address_head_, table_t::address_head); + close(ec, address_body_, table_t::address_body); close(ec, neutrino_head_, table_t::neutrino_head); close(ec, neutrino_body_, table_t::neutrino_body); ////close(ec, bootstrap_head_, table_t::bootstrap_head); @@ -667,21 +678,22 @@ code CLASS::backup(const event_handler& handler) NOEXCEPT }; if (!backup(header, table_t::header_table)) return error::backup_table; - if (!backup(point, table_t::point_table)) return error::backup_table; if (!backup(input, table_t::input_table)) return error::backup_table; if (!backup(output, table_t::output_table)) return error::backup_table; + if (!backup(point, table_t::point_table)) return error::backup_table; if (!backup(puts, table_t::puts_table)) return error::backup_table; + if (!backup(spend, table_t::spend_table)) return error::backup_table; if (!backup(tx, table_t::tx_table)) return error::backup_table; if (!backup(txs, table_t::txs_table)) return error::backup_table; - if (!backup(address, table_t::address_table)) return error::backup_table; if (!backup(candidate, table_t::candidate_table)) return error::backup_table; if (!backup(confirmed, table_t::confirmed_table)) return error::backup_table; - if (!backup(spend, table_t::spend_table)) return error::backup_table; if (!backup(strong_tx, table_t::strong_tx_table)) return error::backup_table; if (!backup(validated_bk, table_t::validated_bk_table)) return error::backup_table; if (!backup(validated_tx, table_t::validated_tx_table)) return error::backup_table; + + if (!backup(address, table_t::address_table)) return error::backup_table; if (!backup(neutrino, table_t::neutrino_table)) return error::backup_table; ////if (!backup(bootstrap, table_t::bootstrap_table)) return error::backup_table; ////if (!backup(buffer, table_t::buffer_table)) return error::backup_table; @@ -713,41 +725,43 @@ code CLASS::dump(const path& folder, const event_handler& handler) NOEXCEPT { auto header_buffer = header_head_.get(); - auto point_buffer = point_head_.get(); auto input_buffer = input_head_.get(); auto output_buffer = output_head_.get(); + auto point_buffer = point_head_.get(); auto puts_buffer = puts_head_.get(); + auto spend_buffer = spend_head_.get(); auto tx_buffer = tx_head_.get(); auto txs_buffer = txs_head_.get(); - auto address_buffer = address_head_.get(); auto candidate_buffer = candidate_head_.get(); auto confirmed_buffer = confirmed_head_.get(); - auto spend_buffer = spend_head_.get(); auto strong_tx_buffer = strong_tx_head_.get(); auto validated_bk_buffer = validated_bk_head_.get(); auto validated_tx_buffer = validated_tx_head_.get(); + + auto address_buffer = address_head_.get(); auto neutrino_buffer = neutrino_head_.get(); ////auto bootstrap_buffer = bootstrap_head_.get(); ////auto buffer_buffer = buffer_head_.get(); if (!header_buffer) return error::unloaded_file; - if (!point_buffer) return error::unloaded_file; if (!input_buffer) return error::unloaded_file; if (!output_buffer) return error::unloaded_file; + if (!point_buffer) return error::unloaded_file; if (!puts_buffer) return error::unloaded_file; + if (!spend_buffer) return error::unloaded_file; if (!tx_buffer) return error::unloaded_file; if (!txs_buffer) return error::unloaded_file; - if (!address_buffer) return error::unloaded_file; if (!candidate_buffer) return error::unloaded_file; if (!confirmed_buffer) return error::unloaded_file; - if (!spend_buffer) return error::unloaded_file; if (!strong_tx_buffer) return error::unloaded_file; if (!validated_bk_buffer) return error::unloaded_file; if (!validated_tx_buffer) return error::unloaded_file; + + if (!address_buffer) return error::unloaded_file; if (!neutrino_buffer) return error::unloaded_file; ////if (!bootstrap_buffer) return error::unloaded_file; ////if (!buffer_buffer) return error::unloaded_file; @@ -762,27 +776,25 @@ code CLASS::dump(const path& folder, if (!dump(header_buffer, schema::archive::header, table_t::header_head)) return error::dump_file; - if (!dump(point_buffer, schema::archive::point, table_t::point_head)) - return error::dump_file; if (!dump(input_buffer, schema::archive::input, table_t::input_head)) return error::dump_file; if (!dump(output_buffer, schema::archive::output, table_t::output_head)) return error::dump_file; + if (!dump(point_buffer, schema::archive::point, table_t::point_head)) + return error::dump_file; if (!dump(puts_buffer, schema::archive::puts, table_t::puts_head)) return error::dump_file; + if (!dump(spend_buffer, schema::archive::spend, table_t::spend_head)) + return error::dump_file; if (!dump(tx_buffer, schema::archive::tx, table_t::tx_head)) return error::dump_file; if (!dump(txs_buffer, schema::archive::txs, table_t::txs_head)) return error::dump_file; - if (!dump(address_buffer, schema::indexes::address, table_t::address_head)) - return error::dump_file; if (!dump(candidate_buffer, schema::indexes::candidate, table_t::candidate_head)) return error::dump_file; if (!dump(confirmed_buffer, schema::indexes::confirmed, table_t::confirmed_head)) return error::dump_file; - if (!dump(spend_buffer, schema::archive::spend, table_t::spend_head)) - return error::dump_file; if (!dump(strong_tx_buffer, schema::indexes::strong_tx, table_t::strong_tx_head)) return error::dump_file; @@ -790,11 +802,14 @@ code CLASS::dump(const path& folder, return error::dump_file; if (!dump(validated_tx_buffer, schema::caches::validated_tx, table_t::validated_tx_head)) return error::dump_file; - if (!dump(neutrino_buffer, schema::caches::neutrino, table_t::neutrino_head)) + + if (!dump(address_buffer, schema::optionals::address, table_t::address_head)) + return error::dump_file; + if (!dump(neutrino_buffer, schema::optionals::neutrino, table_t::neutrino_head)) return error::dump_file; - ////if (!dump(bootstrap_buffer, schema::caches::bootstrap, table_t::bootstrap_head)) + ////if (!dump(bootstrap_buffer, schema::optionals::bootstrap, table_t::bootstrap_head)) //// return error::dump_file; - ////if (!dump(buffer_buffer, schema::caches::buffer, table_t::buffer_head)) + ////if (!dump(buffer_buffer, schema::optionals::buffer, table_t::buffer_head)) //// return error::dump_file; return error::success; @@ -866,21 +881,22 @@ code CLASS::restore(const event_handler& handler) NOEXCEPT ec = open_load(handler); if (!restore(header, table_t::header_table)) ec = error::restore_table; - if (!restore(point, table_t::point_table)) ec = error::restore_table; if (!restore(input, table_t::input_table)) ec = error::restore_table; if (!restore(output, table_t::output_table)) ec = error::restore_table; + if (!restore(point, table_t::point_table)) ec = error::restore_table; if (!restore(puts, table_t::puts_table)) ec = error::restore_table; + if (!restore(spend, table_t::spend_table)) ec = error::restore_table; if (!restore(tx, table_t::tx_table)) ec = error::restore_table; if (!restore(txs, table_t::txs_table)) ec = error::restore_table; - if (!restore(address, table_t::address_table)) ec = error::restore_table; if (!restore(candidate, table_t::candidate_table)) ec = error::restore_table; if (!restore(confirmed, table_t::confirmed_table)) ec = error::restore_table; - if (!restore(spend, table_t::spend_table)) ec = error::restore_table; if (!restore(strong_tx, table_t::strong_tx_table)) ec = error::restore_table; if (!restore(validated_bk, table_t::validated_bk_table)) ec = error::restore_table; if (!restore(validated_tx, table_t::validated_tx_table)) ec = error::restore_table; + + if (!restore(address, table_t::address_table)) ec = error::restore_table; if (!restore(neutrino, table_t::neutrino_table)) ec = error::restore_table; ////if (!restore(bootstrap, table_t::bootstrap_table)) ec = error::restore_table; ////if (!restore(buffer, table_t::buffer_table)) ec = error::restore_table; diff --git a/include/bitcoin/database/settings.hpp b/include/bitcoin/database/settings.hpp index ac58c3e9..1b6ffea1 100644 --- a/include/bitcoin/database/settings.hpp +++ b/include/bitcoin/database/settings.hpp @@ -46,19 +46,23 @@ struct BCD_API settings uint64_t header_size; uint16_t header_rate; - uint32_t point_buckets; - uint64_t point_size; - uint16_t point_rate; - uint64_t input_size; uint16_t input_rate; uint64_t output_size; uint16_t output_rate; + uint32_t point_buckets; + uint64_t point_size; + uint16_t point_rate; + uint64_t puts_size; uint16_t puts_rate; + uint32_t spend_buckets; + uint64_t spend_size; + uint16_t spend_rate; + uint32_t tx_buckets; uint64_t tx_size; uint16_t tx_rate; @@ -70,20 +74,12 @@ struct BCD_API settings /// Indexes. /// ----------------------------------------------------------------------- - uint32_t address_buckets; - uint64_t address_size; - uint16_t address_rate; - uint64_t candidate_size; uint16_t candidate_rate; uint64_t confirmed_size; uint16_t confirmed_rate; - uint32_t spend_buckets; - uint64_t spend_size; - uint16_t spend_rate; - uint32_t strong_tx_buckets; uint64_t strong_tx_size; uint16_t strong_tx_rate; @@ -99,6 +95,13 @@ struct BCD_API settings uint64_t validated_tx_size; uint16_t validated_tx_rate; + /// Optionals. + /// ----------------------------------------------------------------------- + + uint32_t address_buckets; + uint64_t address_size; + uint16_t address_rate; + uint32_t neutrino_buckets; uint64_t neutrino_size; uint16_t neutrino_rate; diff --git a/include/bitcoin/database/store.hpp b/include/bitcoin/database/store.hpp index b9fae125..671ec1cb 100644 --- a/include/bitcoin/database/store.hpp +++ b/include/bitcoin/database/store.hpp @@ -74,23 +74,25 @@ class store /// Archives. table::header header; - table::point point; table::input input; table::output output; + table::point point; table::puts puts; + table::spend spend; table::transaction tx; table::txs txs; /// Indexes. - table::address address; table::height candidate; table::height confirmed; - table::spend spend; table::strong_tx strong_tx; /// Caches. table::validated_bk validated_bk; table::validated_tx validated_tx; + + /// Optionals. + table::address address; table::neutrino neutrino; ////table::bootstrap bootstrap; ////table::buffer buffer; @@ -112,10 +114,6 @@ class store Storage header_head_; Storage header_body_; - // record hashmap - Storage point_head_; - Storage point_body_; - // slab hashmap Storage input_head_; Storage input_body_; @@ -124,10 +122,18 @@ class store Storage output_head_; Storage output_body_; + // record hashmap + Storage point_head_; + Storage point_body_; + // array Storage puts_head_; Storage puts_body_; + // record hashmap + Storage spend_head_; + Storage spend_body_; + // record hashmap Storage tx_head_; Storage tx_body_; @@ -139,10 +145,6 @@ class store /// Indexes. /// ----------------------------------------------------------------------- - // record hashmap - Storage address_head_; - Storage address_body_; - // array Storage candidate_head_; Storage candidate_body_; @@ -151,10 +153,6 @@ class store Storage confirmed_head_; Storage confirmed_body_; - // record hashmap - Storage spend_head_; - Storage spend_body_; - // record hashmap Storage strong_tx_head_; Storage strong_tx_body_; @@ -170,6 +168,13 @@ class store Storage validated_tx_head_; Storage validated_tx_body_; + /// Optionals. + /// ----------------------------------------------------------------------- + + // record hashmap + Storage address_head_; + Storage address_body_; + // slab hashmap Storage neutrino_head_; Storage neutrino_body_; diff --git a/include/bitcoin/database/tables/archives/input.hpp b/include/bitcoin/database/tables/archives/input.hpp index 160f0982..cc43b9b2 100644 --- a/include/bitcoin/database/tables/archives/input.hpp +++ b/include/bitcoin/database/tables/archives/input.hpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace libbitcoin { diff --git a/include/bitcoin/database/tables/indexes/spend.hpp b/include/bitcoin/database/tables/archives/spend.hpp similarity index 98% rename from include/bitcoin/database/tables/indexes/spend.hpp rename to include/bitcoin/database/tables/archives/spend.hpp index f81512e3..bd7ea9a4 100644 --- a/include/bitcoin/database/tables/indexes/spend.hpp +++ b/include/bitcoin/database/tables/archives/spend.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_TABLES_INDEXES_SPEND_HPP -#define LIBBITCOIN_DATABASE_TABLES_INDEXES_SPEND_HPP +#ifndef LIBBITCOIN_DATABASE_TABLES_ARCHIVES_SPEND_HPP +#define LIBBITCOIN_DATABASE_TABLES_ARCHIVES_SPEND_HPP #include #include diff --git a/include/bitcoin/database/tables/indexes/address.hpp b/include/bitcoin/database/tables/optionals/address.hpp similarity index 94% rename from include/bitcoin/database/tables/indexes/address.hpp rename to include/bitcoin/database/tables/optionals/address.hpp index 36acfce0..dc243f85 100644 --- a/include/bitcoin/database/tables/indexes/address.hpp +++ b/include/bitcoin/database/tables/optionals/address.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_TABLES_INDEXES_ADDRESS_HPP -#define LIBBITCOIN_DATABASE_TABLES_INDEXES_ADDRESS_HPP +#ifndef LIBBITCOIN_DATABASE_TABLES_OPTIONALS_ADDRESS_HPP +#define LIBBITCOIN_DATABASE_TABLES_OPTIONALS_ADDRESS_HPP #include #include diff --git a/include/bitcoin/database/tables/caches/bootstrap.hpp b/include/bitcoin/database/tables/optionals/bootstrap.hpp similarity index 96% rename from include/bitcoin/database/tables/caches/bootstrap.hpp rename to include/bitcoin/database/tables/optionals/bootstrap.hpp index 12c36b0e..8c093a51 100644 --- a/include/bitcoin/database/tables/caches/bootstrap.hpp +++ b/include/bitcoin/database/tables/optionals/bootstrap.hpp @@ -16,8 +16,8 @@ //// * You should have received a copy of the GNU Affero General Public License //// * along with this program. If not, see . //// */ -////#ifndef LIBBITCOIN_DATABASE_TABLES_CACHES_BOOTSTRAP_HPP -////#define LIBBITCOIN_DATABASE_TABLES_CACHES_BOOTSTRAP_HPP +////#ifndef LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BOOTSTRAP_HPP +////#define LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BOOTSTRAP_HPP //// ////#include ////#include diff --git a/include/bitcoin/database/tables/caches/buffer.hpp b/include/bitcoin/database/tables/optionals/buffer.hpp similarity index 96% rename from include/bitcoin/database/tables/caches/buffer.hpp rename to include/bitcoin/database/tables/optionals/buffer.hpp index 9f4d3468..52c81e04 100644 --- a/include/bitcoin/database/tables/caches/buffer.hpp +++ b/include/bitcoin/database/tables/optionals/buffer.hpp @@ -16,8 +16,8 @@ //// * You should have received a copy of the GNU Affero General Public License //// * along with this program. If not, see . //// */ -////#ifndef LIBBITCOIN_DATABASE_TABLES_CACHES_BUFFER_HPP -////#define LIBBITCOIN_DATABASE_TABLES_CACHES_BUFFER_HPP +////#ifndef LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BUFFER_HPP +////#define LIBBITCOIN_DATABASE_TABLES_OPTIONALS_BUFFER_HPP //// ////#include ////#include diff --git a/include/bitcoin/database/tables/caches/neutrino.hpp b/include/bitcoin/database/tables/optionals/neutrino.hpp similarity index 97% rename from include/bitcoin/database/tables/caches/neutrino.hpp rename to include/bitcoin/database/tables/optionals/neutrino.hpp index 7c71477e..9d617dfa 100644 --- a/include/bitcoin/database/tables/caches/neutrino.hpp +++ b/include/bitcoin/database/tables/optionals/neutrino.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_DATABASE_TABLES_CACHES_NEUTRINO_HPP -#define LIBBITCOIN_DATABASE_TABLES_CACHES_NEUTRINO_HPP +#ifndef LIBBITCOIN_DATABASE_TABLES_OPTIONALS_NEUTRINO_HPP +#define LIBBITCOIN_DATABASE_TABLES_OPTIONALS_NEUTRINO_HPP #include #include diff --git a/include/bitcoin/database/tables/schema.hpp b/include/bitcoin/database/tables/schema.hpp index c09b44b9..11f0799a 100644 --- a/include/bitcoin/database/tables/schema.hpp +++ b/include/bitcoin/database/tables/schema.hpp @@ -44,18 +44,17 @@ namespace schema namespace archive { constexpr auto header = "archive_header"; - constexpr auto point = "archive_point"; constexpr auto input = "archive_input"; constexpr auto output = "archive_output"; - constexpr auto spend = "archive_spend"; + constexpr auto point = "archive_point"; constexpr auto puts = "archive_puts"; - constexpr auto txs = "archive_txs"; + constexpr auto spend = "archive_spend"; constexpr auto tx = "archive_tx"; + constexpr auto txs = "archive_txs"; } namespace indexes { - constexpr auto address = "address"; constexpr auto candidate = "candidate"; constexpr auto confirmed = "confirmed"; constexpr auto strong_tx = "strong_tx"; @@ -63,13 +62,18 @@ namespace schema namespace caches { - constexpr auto bootstrap = "bootstrap"; - constexpr auto buffer = "buffer"; - constexpr auto neutrino = "neutrino"; constexpr auto validated_bk = "validated_bk"; constexpr auto validated_tx = "validated_tx"; } + namespace optionals + { + constexpr auto address = "address"; + constexpr auto neutrino = "neutrino"; + ////constexpr auto bootstrap = "bootstrap"; + ////constexpr auto buffer = "buffer"; + } + namespace locks { constexpr auto flush = "flush"; @@ -116,8 +120,8 @@ namespace schema constexpr size_t block = 3; // ->header record. constexpr size_t bk_slab = 3; // ->validated_bk record. constexpr size_t tx_slab = 5; // ->validated_tk record. - constexpr size_t buffer_ = 5; // ->buffer record (guestimate). - constexpr size_t neutrino_ = 5; // ->neutrino record (guestimate). + constexpr size_t neutrino_ = 5; // ->neutrino record. + ////constexpr size_t buffer_ = 5; // ->buffer record (guestimate). /// Search keys. constexpr size_t hash = system::hash_size; diff --git a/include/bitcoin/database/tables/table.hpp b/include/bitcoin/database/tables/table.hpp index c028f08e..599ec642 100644 --- a/include/bitcoin/database/tables/table.hpp +++ b/include/bitcoin/database/tables/table.hpp @@ -26,21 +26,25 @@ enum class table_t { store, + /// Archives. header_table, header_head, header_body, - point_table, - point_head, - point_body, input_table, input_head, input_body, output_table, output_head, output_body, + point_table, + point_head, + point_body, puts_table, puts_head, puts_body, + spend_table, + spend_head, + spend_body, tx_table, tx_head, txs_table, @@ -48,37 +52,38 @@ enum class table_t txs_head, txs_body, - address_table, - address_head, - address_body, + /// Indexes. candidate_table, candidate_head, candidate_body, confirmed_table, confirmed_head, confirmed_body, - spend_table, - spend_head, - spend_body, strong_tx_table, strong_tx_head, strong_tx_body, + /// Caches. + validated_bk_table, + validated_bk_head, + validated_bk_body, + validated_tx_table, + validated_tx_head, + validated_tx_body, + + /// Optionals. + address_table, + address_head, + address_body, + neutrino_table, + neutrino_head, + neutrino_body, ////bootstrap_table, ////bootstrap_head, ////bootstrap_body, ////buffer_table, ////buffer_head, ////buffer_body, - neutrino_table, - neutrino_head, - neutrino_body, - validated_bk_table, - validated_bk_head, - validated_bk_body, - validated_tx_table, - validated_tx_head, - validated_tx_body }; } // namespace database diff --git a/include/bitcoin/database/tables/tables.hpp b/include/bitcoin/database/tables/tables.hpp index 82666adf..c301ccf6 100644 --- a/include/bitcoin/database/tables/tables.hpp +++ b/include/bitcoin/database/tables/tables.hpp @@ -24,20 +24,21 @@ #include #include #include +#include #include #include -////#include -////#include -#include #include #include -#include #include -#include #include +#include +#include + ////#include + ////#include + #include #include #include diff --git a/src/settings.cpp b/src/settings.cpp index bb6cde2f..f508ede0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -35,19 +35,23 @@ settings::settings() NOEXCEPT header_size{ 1 }, header_rate{ 50 }, - point_buckets{ 100 }, - point_size{ 1 }, - point_rate{ 50 }, - input_size{ 1 }, input_rate{ 50 }, output_size{ 1 }, output_rate{ 50 }, + point_buckets{ 100 }, + point_size{ 1 }, + point_rate{ 50 }, + puts_size{ 1 }, puts_rate{ 50 }, + spend_buckets{ 100 }, + spend_size{ 1 }, + spend_rate{ 50 }, + tx_buckets{ 100 }, tx_size{ 1 }, tx_rate{ 50 }, @@ -58,20 +62,12 @@ settings::settings() NOEXCEPT // Indexes. - address_buckets{ 100 }, - address_size{ 1 }, - address_rate{ 50 }, - candidate_size{ 1 }, candidate_rate{ 50 }, confirmed_size{ 1 }, confirmed_rate{ 50 }, - spend_buckets{ 100 }, - spend_size{ 1 }, - spend_rate{ 50 }, - strong_tx_buckets{ 100 }, strong_tx_size{ 1 }, strong_tx_rate{ 50 }, @@ -86,10 +82,18 @@ settings::settings() NOEXCEPT validated_tx_size{ 1 }, validated_tx_rate{ 50 }, + // Optionals. + + address_buckets{ 100 }, + address_size{ 1 }, + address_rate{ 50 }, + neutrino_buckets{ 100 }, neutrino_size{ 1 }, neutrino_rate{ 50 } + // Caches. + ////bootstrap_size{ 1 }, ////bootstrap_rate{ 50 },