diff --git a/include/bitcoin/database/impl/primitives/arraymap.ipp b/include/bitcoin/database/impl/primitives/arraymap.ipp index 26628c66..6c999c3d 100644 --- a/include/bitcoin/database/impl/primitives/arraymap.ipp +++ b/include/bitcoin/database/impl/primitives/arraymap.ipp @@ -163,7 +163,7 @@ bool CLASS::put_link(Link& link, const Element& element) NOEXCEPT iostream stream{ *ptr }; flipper sink{ stream }; - if constexpr (!is_slab) { sink.set_limit(Size * count); } + if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) } return element.to_data(sink); } diff --git a/include/bitcoin/database/impl/primitives/hashmap.ipp b/include/bitcoin/database/impl/primitives/hashmap.ipp index f9c4c93f..aa2505b4 100644 --- a/include/bitcoin/database/impl/primitives/hashmap.ipp +++ b/include/bitcoin/database/impl/primitives/hashmap.ipp @@ -154,6 +154,7 @@ Link CLASS::first(const Key& key) const NOEXCEPT TEMPLATE typename CLASS::iterator CLASS::it(const Key& key) const NOEXCEPT { + // (14.09% + 5.36%) // Expensive construction, avoid unless iteration is necessary. return { manager_.get(), head_.top(key), key }; } @@ -270,7 +271,8 @@ bool CLASS::put_link(Link& link, const Key& key, return head_.push(link, next, index); }); - if constexpr (!is_slab) { sink.set_limit(Size * count); } + // (1.63%) + if constexpr (!is_slab) { BC_DEBUG_ONLY(sink.set_limit(Size * count);) } return element.to_data(sink) && sink.finalize(); } diff --git a/include/bitcoin/database/impl/query/confirm.ipp b/include/bitcoin/database/impl/query/confirm.ipp index d8ea0196..96651e48 100644 --- a/include/bitcoin/database/impl/query/confirm.ipp +++ b/include/bitcoin/database/impl/query/confirm.ipp @@ -404,6 +404,7 @@ bool CLASS::is_strong(const header_link& link) const NOEXCEPT TEMPLATE bool CLASS::set_strong(const header_link& link) NOEXCEPT { + // (0.22%) after milestone. const auto txs = to_transactions(link); if (txs.empty()) return false; @@ -411,6 +412,7 @@ bool CLASS::set_strong(const header_link& link) NOEXCEPT // ======================================================================== const auto scope = store_.get_transactor(); + // (4.04%) after milestone. // Clean allocation failure (e.g. disk full), see set_strong() comments. return set_strong(link, txs, true); // ======================================================================== diff --git a/include/bitcoin/database/impl/query/translate.ipp b/include/bitcoin/database/impl/query/translate.ipp index a1e71565..870bae98 100644 --- a/include/bitcoin/database/impl/query/translate.ipp +++ b/include/bitcoin/database/impl/query/translate.ipp @@ -201,14 +201,8 @@ header_link CLASS::to_parent(const header_link& link) const NOEXCEPT TEMPLATE header_link CLASS::to_block(const tx_link& link) const NOEXCEPT { - // (10.99%) from block_confirmable->unspendable_prevout->to_strong->to_block. - - // (8.25%) - ////const auto to_strong_tx_link = store_.strong_tx.first(link); - - // (2.68%) + // (10.36%) table::strong_tx::record strong{}; - ////if (!store_.strong_tx.get(to_strong_tx_link, strong)) if (!store_.strong_tx.find(link, strong)) return {}; @@ -404,7 +398,8 @@ spend_links CLASS::to_spenders(const foreign_point& point) const NOEXCEPT // Iterate transactions that spend the point, saving each spender. spend_links spenders{}; do - { // BUGBUG: Deadlock due to holding iterator while querying own table. + { + // BUGBUG: Deadlock due to holding iterator while querying own table. // TODO: refactor to make safe and also pass boolean result code. spenders.push_back(to_spender(to_spend_tx(it.self()), point)); } @@ -477,7 +472,6 @@ TEMPLATE tx_links CLASS::to_transactions(const header_link& link) const NOEXCEPT { table::txs::slab txs{}; - ////if (!store_.txs.get(to_txs(link), txs)) if (!store_.txs.find(link, txs)) return {}; @@ -488,7 +482,6 @@ TEMPLATE tx_link CLASS::to_coinbase(const header_link& link) const NOEXCEPT { table::txs::get_coinbase txs{}; - ////if (!store_.txs.get(to_txs(link), txs)) if (!store_.txs.find(link, txs)) return {}; diff --git a/include/bitcoin/database/impl/query/validate.ipp b/include/bitcoin/database/impl/query/validate.ipp index e1aac3b3..0f589854 100644 --- a/include/bitcoin/database/impl/query/validate.ipp +++ b/include/bitcoin/database/impl/query/validate.ipp @@ -125,6 +125,7 @@ bool CLASS::get_bits(uint32_t& bits, const header_link& link) const NOEXCEPT TEMPLATE bool CLASS::get_context(context& ctx, const header_link& link) const NOEXCEPT { + // (4.04%) table::header::record_context header{}; if (!store_.header.get(link, header)) return false; diff --git a/include/bitcoin/database/tables/schema.hpp b/include/bitcoin/database/tables/schema.hpp index a55f4c26..b3238e7d 100644 --- a/include/bitcoin/database/tables/schema.hpp +++ b/include/bitcoin/database/tables/schema.hpp @@ -163,6 +163,7 @@ namespace schema schema::put; static constexpr size_t minrow = minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 9u); static_assert(minrow == 9u); }; @@ -199,6 +200,7 @@ namespace schema 1u; // variable_size (minimum 1, average 1) static constexpr size_t minrow = minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 2u); static_assert(minrow == 2u); }; @@ -214,6 +216,7 @@ namespace schema 1u; // variable_size (minimum 1, average 1) static constexpr size_t minrow = minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 10u); static_assert(minrow == 10u); }; @@ -262,6 +265,7 @@ namespace schema transaction::pk; // coinbase static constexpr size_t minrow = pk + sk + minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 11u); static_assert(minrow == 19u); }; @@ -328,6 +332,7 @@ namespace schema one; static constexpr size_t minrow = pk + sk + minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 2u); static_assert(minrow == 8u); }; @@ -347,6 +352,7 @@ namespace schema one; static constexpr size_t minrow = pk + sk + minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 14u); static_assert(minrow == 23u); }; @@ -362,6 +368,7 @@ namespace schema one; static constexpr size_t minrow = pk + sk + minsize; static constexpr size_t size = max_size_t; + static inline linkage count() NOEXCEPT; static_assert(minsize == 33u); static_assert(minrow == 41u); }; @@ -388,6 +395,7 @@ namespace schema //// static constexpr size_t minsize = zero; //// static constexpr size_t minrow = pk + sk + minsize; //// static constexpr size_t size = max_size_t; + //// static inline linkage count() NOEXCEPT; //// static_assert(minsize == 0u); //// static_assert(minrow == 9u); ////};