Skip to content

Commit

Permalink
Incorporate prevout table into store.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Jan 11, 2025
1 parent a40b385 commit f9c9550
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 71 deletions.
88 changes: 48 additions & 40 deletions include/bitcoin/database/impl/store.ipp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions include/bitcoin/database/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ struct BCD_API settings
/// Caches.
/// -----------------------------------------------------------------------

uint32_t prevout_buckets;
uint64_t prevout_size;
uint16_t prevout_rate;

uint32_t validated_bk_buckets;
uint64_t validated_bk_size;
uint16_t validated_bk_rate;
Expand All @@ -109,10 +113,6 @@ struct BCD_API settings

////uint32_t bootstrap_size;
////uint16_t bootstrap_rate;

////uint32_t buffer_buckets;
////uint64_t buffer_size;
////uint16_t buffer_rate;
};

} // namespace database
Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/database/store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ class store
table::strong_tx strong_tx;

/// Caches.
table::prevout prevout;
table::validated_bk validated_bk;
table::validated_tx validated_tx;

/// Optionals.
table::address address;
table::neutrino neutrino;
////table::bootstrap bootstrap;
////table::buffer buffer;

protected:
code open_load(const event_handler& handler) NOEXCEPT;
Expand Down Expand Up @@ -185,6 +185,10 @@ class store
/// Caches.
/// -----------------------------------------------------------------------

// record arraymap
Storage prevout_head_;
Storage prevout_body_;

// record hashmap
Storage validated_bk_head_;
Storage validated_bk_body_;
Expand All @@ -208,10 +212,6 @@ class store
////Storage bootstrap_head_;
////Storage bootstrap_body_;

////// slab hashmap
////Storage buffer_head_;
////Storage buffer_body_;

/// Locks.
/// -----------------------------------------------------------------------

Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/database/tables/table.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ enum class table_t
strong_tx_body,

/// Caches.
prevout_table,
prevout_head,
prevout_body,
validated_bk_table,
validated_bk_head,
validated_bk_body,
Expand All @@ -77,13 +80,10 @@ enum class table_t
address_body,
neutrino_table,
neutrino_head,
neutrino_body,
neutrino_body
////bootstrap_table,
////bootstrap_head,
////bootstrap_body,
////buffer_table,
////buffer_head,
////buffer_body,
////bootstrap_body
};

} // namespace database
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/tables/tables.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <bitcoin/database/tables/archives/transaction.hpp>
#include <bitcoin/database/tables/archives/txs.hpp>

#include <bitcoin/database/tables/caches/prevout.hpp>
#include <bitcoin/database/tables/caches/validated_bk.hpp>
#include <bitcoin/database/tables/caches/validated_tx.hpp>

Expand All @@ -37,7 +38,6 @@
#include <bitcoin/database/tables/optionals/address.hpp>
#include <bitcoin/database/tables/optionals/neutrino.hpp>
////#include <bitcoin/database/tables/optionals/bootstrap.hpp>
////#include <bitcoin/database/tables/optionals/buffer.hpp>

#include <bitcoin/database/tables/context.hpp>
#include <bitcoin/database/tables/event.hpp>
Expand Down
12 changes: 5 additions & 7 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ settings::settings() NOEXCEPT

// Caches.

prevout_buckets{ 100 },
prevout_size{ 1 },
prevout_rate{ 50 },

validated_bk_buckets{ 100 },
validated_bk_size{ 1 },
validated_bk_rate{ 50 },
Expand All @@ -93,14 +97,8 @@ settings::settings() NOEXCEPT
neutrino_size{ 1 },
neutrino_rate{ 50 }

// Caches.

////bootstrap_size{ 1 },
////bootstrap_rate{ 50 },

////buffer_buckets{ 100 },
////buffer_size{ 1 },
////buffer_rate{ 50 }
////bootstrap_rate{ 50 }
{
}

Expand Down
20 changes: 11 additions & 9 deletions test/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ BOOST_AUTO_TEST_CASE(settings__construct__default__expected)
BOOST_REQUIRE_EQUAL(configuration.output_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.puts_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.puts_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.spend_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.spend_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.spend_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.tx_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.tx_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.tx_rate, 50u);
Expand All @@ -47,35 +50,34 @@ BOOST_AUTO_TEST_CASE(settings__construct__default__expected)
BOOST_REQUIRE_EQUAL(configuration.txs_rate, 50u);

// Indexes.
BOOST_REQUIRE_EQUAL(configuration.address_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.address_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.address_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.candidate_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.candidate_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.confirmed_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.confirmed_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.spend_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.spend_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.spend_rate, 50u);
BOOST_REQUIRE_EQUAL(configuration.strong_tx_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.strong_tx_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.strong_tx_rate, 50u);

// Caches.
BOOST_REQUIRE_EQUAL(configuration.prevout_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.prevout_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.prevout_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);

// Optionals.
BOOST_REQUIRE_EQUAL(configuration.address_buckets, 100u);
BOOST_REQUIRE_EQUAL(configuration.address_size, 1u);
BOOST_REQUIRE_EQUAL(configuration.address_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()

0 comments on commit f9c9550

Please sign in to comment.