diff --git a/include/bitcoin/database/impl/query/archive/chain_writer.ipp b/include/bitcoin/database/impl/query/archive/chain_writer.ipp index e568a69c2..672c5f1e8 100644 --- a/include/bitcoin/database/impl/query/archive/chain_writer.ipp +++ b/include/bitcoin/database/impl/query/archive/chain_writer.ipp @@ -409,8 +409,7 @@ code CLASS::set_code(const block& block, const header_link& key, constexpr auto positive = true; // Transactor assures cannot be restored without txs, as required to unset. - // Sequential write, as archival is already concurrent across blocks. - if (strong && !set_strong(key, txs, tx_fks, positive, false)) + if (strong && !set_strong(key, txs, tx_fks, positive)) return error::txs_confirm; // Header link is the key for the txs table. diff --git a/include/bitcoin/database/impl/query/archive/wire_writer.ipp b/include/bitcoin/database/impl/query/archive/wire_writer.ipp index 950fd7cad..8248ed2cc 100644 --- a/include/bitcoin/database/impl/query/archive/wire_writer.ipp +++ b/include/bitcoin/database/impl/query/archive/wire_writer.ipp @@ -347,8 +347,7 @@ code CLASS::set_code(const block_view& block, const header_link& key, constexpr auto positive = true; // Transactor assures cannot be restored without txs, as required to unset. - // Sequential write, as archival is already concurrent across blocks. - if (strong && !set_strong(key, txs, tx_fks, positive, false)) + if (strong && !set_strong(key, txs, tx_fks, positive)) return error::txs_confirm; // Header link is the key for the txs table. diff --git a/include/bitcoin/database/impl/query/consensus/consensus_strong.ipp b/include/bitcoin/database/impl/query/consensus/consensus_strong.ipp index 7f1853e49..f16848de9 100644 --- a/include/bitcoin/database/impl/query/consensus/consensus_strong.ipp +++ b/include/bitcoin/database/impl/query/consensus/consensus_strong.ipp @@ -19,7 +19,6 @@ #ifndef LIBBITCOIN_DATABASE_QUERY_CONSENSUS_STRONG_IPP #define LIBBITCOIN_DATABASE_QUERY_CONSENSUS_STRONG_IPP -#include #include namespace libbitcoin { @@ -108,33 +107,27 @@ header_link CLASS::find_strong(const hash_digest& tx_hash) const NOEXCEPT // protected TEMPLATE bool CLASS::set_strong(const header_link& link, size_t count, - const tx_link& first_fk, bool positive, bool parallel) NOEXCEPT + const tx_link& first_fk, bool positive) NOEXCEPT { using namespace system; using link_t = table::strong_tx::link; using element_t = table::strong_tx::record; - const auto policy = poolstl::execution::par_if(parallel); // Preallocate all strong_tx records for the block and reuse memory ptr. - // Terminal allocation must not be indexed (would wrap to valid records). const auto records = possible_narrow_cast(count); - const auto record = store_.strong_tx.allocate(records); - if (record.is_terminal()) - return false; - + auto record = store_.strong_tx.allocate(records); const auto ptr = store_.strong_tx.get_memory(); + const auto end = first_fk + count; + + // Contiguous tx links. + for (auto fk = first_fk; fk < end; ++fk) + if (!store_.strong_tx.put(ptr, record++, fk, element_t + { + {}, + table::strong_tx::merge(positive, link) + })) return false; - // All records of the block share one element value. - const element_t element{ {}, table::strong_tx::merge(positive, link) }; - - // Contiguous tx links to contiguous records. - return std::all_of(policy, poolstl::iota_iter(zero), - poolstl::iota_iter(count), - [&](size_t index) NOEXCEPT - { - return store_.strong_tx.put(ptr, record + index, first_fk + index, - element); - }); + return true; } TEMPLATE @@ -151,7 +144,7 @@ bool CLASS::set_strong(const header_link& link) NOEXCEPT const auto scope = get_transactor(); // Clean allocation failure (e.g. disk full). - return set_strong(link, txs.number, txs.coinbase_fk, true, true); + return set_strong(link, txs.number, txs.coinbase_fk , true); // ======================================================================== } @@ -169,7 +162,7 @@ bool CLASS::set_unstrong(const header_link& link) NOEXCEPT const auto scope = get_transactor(); // Clean allocation failure (e.g. disk full). - return set_strong(link, txs.number, txs.coinbase_fk, false, true); + return set_strong(link, txs.number, txs.coinbase_fk, false); // ======================================================================== } diff --git a/include/bitcoin/database/impl/query/height.ipp b/include/bitcoin/database/impl/query/height.ipp index ee9db7e7c..f9c4ac4f4 100644 --- a/include/bitcoin/database/impl/query/height.ipp +++ b/include/bitcoin/database/impl/query/height.ipp @@ -85,7 +85,7 @@ bool CLASS::push_confirmed(const header_link& link, bool strong) NOEXCEPT const auto scope = get_transactor(); // This reservation guard assumes no concurrent writes to the table. - if (strong && !set_strong(link, txs.number, txs.coinbase_fk, true, true)) + if (strong && !set_strong(link, txs.number, txs.coinbase_fk, true)) return false; const table::height::record confirmed{ {}, link }; @@ -110,7 +110,7 @@ bool CLASS::pop_confirmed() NOEXCEPT const auto scope = get_transactor(); // Clean single allocation failure. - if (!set_strong(link, txs.number, txs.coinbase_fk, false, true)) + if (!set_strong(link, txs.number, txs.coinbase_fk, false)) return false; /////////////////////////////////////////////////////////////////////////// diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index 0ba841216..b1d505f59 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -837,7 +837,7 @@ class query /// Support set_strong and set_unstrong writers. bool set_strong(const header_link& link, size_t count, - const tx_link& first_fk, bool positive, bool parallel) NOEXCEPT; + const tx_link& first_fk, bool positive) NOEXCEPT; /// Get all tx links for any point of block that is also in duplicate table. bool get_doubles(tx_links& out, const block& block) const NOEXCEPT;