diff --git a/include/bitcoin/database/impl/query/translate.ipp b/include/bitcoin/database/impl/query/translate.ipp index 516fb22f9..2c27383e4 100644 --- a/include/bitcoin/database/impl/query/translate.ipp +++ b/include/bitcoin/database/impl/query/translate.ipp @@ -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 @@ -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 { @@ -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) diff --git a/include/bitcoin/database/query.hpp b/include/bitcoin/database/query.hpp index aaa5b02a2..632988a7f 100644 --- a/include/bitcoin/database/query.hpp +++ b/include/bitcoin/database/query.hpp @@ -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;