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
34 changes: 27 additions & 7 deletions include/bitcoin/database/impl/query/translate.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ output_link CLASS::to_prevout(const point_link& link) const NOEXCEPT
// block/tx to block (reverse navigation)
// ----------------------------------------------------------------------------

// Required for confirmation processing.
TEMPLATE
header_link CLASS::to_block(const tx_link& key) const NOEXCEPT
{
table::strong_tx::record strong{};
if (!store_.strong_tx.find(key, strong) || !strong.positive())
return {};

// Terminal implies not in strong block (reorganized).
return strong.header_fk();
}

// Required for confirmation processing.
TEMPLATE
header_link CLASS::to_strong(const hash_digest& tx_hash) const NOEXCEPT
Expand All @@ -184,7 +196,6 @@ header_link CLASS::to_strong(const hash_digest& tx_hash) const NOEXCEPT

return {};
}

TEMPLATE
header_link CLASS::to_parent(const header_link& link) const NOEXCEPT
{
Expand All @@ -196,16 +207,25 @@ header_link CLASS::to_parent(const header_link& link) const NOEXCEPT
return header.parent_fk;
}

// to confirmed objects (reverse navigation)
// ----------------------------------------------------------------------------

TEMPLATE
header_link CLASS::to_block(const tx_link& key) const NOEXCEPT
header_link CLASS::to_confirmed_block(
const hash_digest& tx_hash) const NOEXCEPT
{
// Required for confirmation processing.
table::strong_tx::record strong{};
if (!store_.strong_tx.find(key, strong) || !strong.positive())
const auto block = to_strong(tx_hash);
if (!is_confirmed_block(block))
return {};

// Terminal implies not in strong block (reorganized).
return strong.header_fk();
return block;
}

TEMPLATE
point_link CLASS::to_confirmed_spender(const point&) const NOEXCEPT
{
// TODO: implement.
return {};
}

// output to spenders (reverse navigation)
Expand Down
6 changes: 5 additions & 1 deletion include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,13 @@ class query
output_link to_prevout(const point_link& link) const NOEXCEPT;

/// block/tx to block (reverse navigation)
header_link to_block(const tx_link& key) const NOEXCEPT;
header_link to_strong(const hash_digest& tx_hash) const NOEXCEPT;
header_link to_parent(const header_link& link) const NOEXCEPT;
header_link to_block(const tx_link& key) const NOEXCEPT;

/// to confirmed objects (reverse navigation)
header_link to_confirmed_block(const hash_digest& tx_hash) const NOEXCEPT;
point_link to_confirmed_spender(const point& prevout) const NOEXCEPT;

/// output to spenders (reverse navigation)
point_links to_spenders(const point& prevout) const NOEXCEPT;
Expand Down
Loading