Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions include/bitcoin/database/impl/query/archive/chain_writer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions include/bitcoin/database/impl/query/archive/wire_writer.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 14 additions & 21 deletions include/bitcoin/database/impl/query/consensus/consensus_strong.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#ifndef LIBBITCOIN_DATABASE_QUERY_CONSENSUS_STRONG_IPP
#define LIBBITCOIN_DATABASE_QUERY_CONSENSUS_STRONG_IPP

#include <algorithm>
#include <bitcoin/database/define.hpp>

namespace libbitcoin {
Expand Down Expand Up @@ -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<link_t::integer>(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<size_t>(zero),
poolstl::iota_iter<size_t>(count),
[&](size_t index) NOEXCEPT
{
return store_.strong_tx.put(ptr, record + index, first_fk + index,
element);
});
return true;
}

TEMPLATE
Expand All @@ -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);
// ========================================================================
}

Expand All @@ -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);
// ========================================================================
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/impl/query/height.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;

///////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading