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
27 changes: 19 additions & 8 deletions include/bitcoin/database/impl/query/translate.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -411,33 +411,44 @@ output_links CLASS::to_block_prevouts(const header_link& link) const NOEXCEPT
// ----------------------------------------------------------------------------

TEMPLATE
tx_link CLASS::to_coinbase(const header_link& link) const NOEXCEPT
tx_links CLASS::to_transactions(const header_link& link) const NOEXCEPT
{
table::txs::get_coinbase txs{};
table::txs::get_txs txs{};
if (!store_.txs.at(to_txs(link), txs))
return {};

return txs.coinbase_fk;
return std::move(txs.tx_fks);
}

TEMPLATE
tx_links CLASS::to_transactions(const header_link& link) const NOEXCEPT
tx_links CLASS::to_spending_txs(const header_link& link) const NOEXCEPT
{
table::txs::get_txs txs{};
table::txs::get_spending_txs txs{};
if (!store_.txs.at(to_txs(link), txs))
return {};

return std::move(txs.tx_fks);
}

TEMPLATE
tx_links CLASS::to_spending_txs(const header_link& link) const NOEXCEPT
tx_link CLASS::to_coinbase(const header_link& link) const NOEXCEPT
{
table::txs::get_spending_txs txs{};
table::txs::get_coinbase txs{};
if (!store_.txs.at(to_txs(link), txs))
return {};

return std::move(txs.tx_fks);
return txs.coinbase_fk;
}

TEMPLATE
tx_link CLASS::to_transaction(const header_link& link,
size_t position) const NOEXCEPT
{
table::txs::get_tx txs{ {}, position };
if (!store_.txs.at(to_txs(link), txs))
return {};

return txs.tx_fk;
}

// header to arraymap tables (guard domain transitions)
Expand Down
4 changes: 3 additions & 1 deletion include/bitcoin/database/query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,11 @@ class query
output_links to_block_prevouts(const header_link& link) const NOEXCEPT;

/// block to txs (forward navigation)
tx_link to_coinbase(const header_link& link) const NOEXCEPT;
tx_links to_transactions(const header_link& link) const NOEXCEPT;
tx_links to_spending_txs(const header_link& link) const NOEXCEPT;
tx_link to_coinbase(const header_link& link) const NOEXCEPT;
tx_link to_transaction(const header_link& link,
size_t position) const NOEXCEPT;

/// header to arraymap tables (guard domain transitions)
constexpr size_t to_validated_bk(const header_link& link) const NOEXCEPT;
Expand Down
28 changes: 28 additions & 0 deletions include/bitcoin/database/tables/archives/txs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,34 @@ struct txs
tx::integer coinbase_fk{};
};

struct get_tx
: public schema::txs
{
link count() const NOEXCEPT
{
BC_ASSERT(false);
return {};
}

inline bool from_data(reader& source) NOEXCEPT
{
const auto number = source.read_little_endian<ct::integer, ct::size>();
source.skip_bytes(bytes::size);
if (number > position)
{
source.skip_bytes(position * tx::size);
tx_fk = source.read_little_endian<tx::integer, tx::size>();
return source;
}

source.invalidate();
return source;
}

const size_t position{};
tx::integer tx_fk{};
};

struct get_block_size
: public schema::txs
{
Expand Down
Loading