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
17 changes: 1 addition & 16 deletions include/bitcoin/database/impl/query/confirmed.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace database {

// find_confirmed
// ----------------------------------------------------------------------------
// These ensure both strong and candidate/confirmed indexation.

TEMPLATE
header_link CLASS::find_confirmed_block(
Expand Down Expand Up @@ -120,22 +121,6 @@ bool CLASS::is_spent_output(const output_link& link) const NOEXCEPT
});
}

// is_strong
// ----------------------------------------------------------------------------

TEMPLATE
bool CLASS::is_strong_tx(const tx_link& link) const NOEXCEPT
{
table::strong_tx::record strong{};
return store_.strong_tx.find(link, strong) && strong.positive();
}

TEMPLATE
bool CLASS::is_strong_block(const header_link& link) const NOEXCEPT
{
return is_strong_tx(to_coinbase(link));
}

} // namespace database
} // namespace libbitcoin

Expand Down
16 changes: 11 additions & 5 deletions include/bitcoin/database/impl/query/consensus/consensus_strong.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@
namespace libbitcoin {
namespace database {

// is_any_strong
// is_strong
// ----------------------------------------------------------------------------
// True if any tx.link for same tx.hash is associated to a strong block.

TEMPLATE
bool CLASS::is_any_strong(const tx_link& tx) const NOEXCEPT
bool CLASS::is_strong_tx(const tx_link& link) const NOEXCEPT
{
// Try all txs with same hash as self (any instance will suffice).
return !find_strong(get_tx_key(tx)).is_terminal();
return !find_strong_tx(link).is_terminal();
}

TEMPLATE
bool CLASS::is_strong_block(const header_link& link) const NOEXCEPT
{
return is_strong_tx(to_coinbase(link));
}

// find_strong_tx
// find_strong
// ----------------------------------------------------------------------------
// Return the tx.link for same tx.hash with strong association to block.

Expand Down
17 changes: 13 additions & 4 deletions include/bitcoin/database/impl/query/properties_tx.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,22 @@ bool CLASS::get_tx_height(size_t& out, const tx_link& link) const NOEXCEPT
TEMPLATE
bool CLASS::get_tx_position(size_t& out, const tx_link& link) const NOEXCEPT
{
const auto fk = find_strong(link);
if (!is_confirmed_block(fk))
// False implies strong block association not found.
const auto block = find_strong(link);
if (!is_confirmed_block(block))
return false;

// False return below implies an integrity error (tx should be indexed).
// False return implies an integrity error (tx should be indexed).
return get_tx_position(out, link, block);
}

TEMPLATE
bool CLASS::get_tx_position(size_t& out, const tx_link& link,
const header_link& block) const NOEXCEPT
{
// False return implies an integrity error (tx must be indexed).
table::txs::get_position txs{ {}, link };
if (!store_.txs.at(to_txs(fk), txs))
if (!store_.txs.at(to_txs(block), txs))
return false;

out = txs.position;
Expand Down
3 changes: 2 additions & 1 deletion include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ class query
/// False position implies not confirmed (or fault).
bool get_tx_height(size_t& out, const tx_link& link) const NOEXCEPT;
bool get_tx_position(size_t& out, const tx_link& link) const NOEXCEPT;
bool get_tx_position(size_t& out, const tx_link& link,
const header_link& block) const NOEXCEPT;
tx_link get_position_tx(const header_link& link,
size_t position) const NOEXCEPT;

Expand Down Expand Up @@ -565,7 +567,6 @@ class query

code block_confirmable(const header_link& link) const NOEXCEPT;

bool is_any_strong(const tx_link& link) const NOEXCEPT;
bool set_strong(const header_link& link) NOEXCEPT;
bool set_unstrong(const header_link& link) NOEXCEPT;
bool set_prevouts(const header_link& link, const block& block) NOEXCEPT;
Expand Down
Loading