Skip to content

Commit

Permalink
No need to read spend.parent_fk in confirm.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Apr 18, 2024
1 parent 0f28f71 commit cf51602
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 2 additions & 5 deletions include/bitcoin/database/impl/query/confirm.ipp
Expand Up @@ -326,17 +326,14 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
return ec;

uint32_t version{};
table::spend::get_prevout_parent_sequence spend{};
table::spend::get_prevout_sequence spend{};
for (auto tx = std::next(txs.begin()); tx != txs.end(); ++tx)
{
for (const auto& spend_fk: to_tx_spends(version, *tx))
{
if (!store_.spend.get(spend_fk, spend))
return error::integrity;

// TODO: don't read spend.parent_fk.
BC_ASSERT(spend.parent_fk == *tx);

if ((ec = spendable_prevout(spend.point_fk, spend.sequence,
version, ctx)))
return ec;
Expand Down Expand Up @@ -510,7 +507,7 @@ bool CLASS::pop_confirmed() NOEXCEPT
//// if (!get_context(ctx, link))
//// return false;
////
//// table::input::get_prevout_parent_sequence input{};
//// table::input::get_prevout_sequence input{};
//// for (const auto& in: to_non_coinbase_inputs(link))
//// {
//// if (!store_.input.get(in, input))
Expand Down
5 changes: 2 additions & 3 deletions include/bitcoin/database/tables/indexes/spend.hpp
Expand Up @@ -219,7 +219,7 @@ struct spend
tx::integer parent_fk{};
};

struct get_prevout_parent_sequence
struct get_prevout_sequence
: public schema::spend
{
inline bool from_data(reader& source) NOEXCEPT
Expand All @@ -231,7 +231,7 @@ struct spend
if (null_point(point_fk))
point_index = system::chain::point::null_index;

parent_fk = source.read_little_endian<tx::integer, tx::size>();
source.skip_bytes(tx::size);
sequence = source.read_little_endian<uint32_t>();
return source;
}
Expand All @@ -248,7 +248,6 @@ struct spend

pt::integer point_fk{};
ix::integer point_index{};
tx::integer parent_fk{};
uint32_t sequence{};
};

Expand Down

0 comments on commit cf51602

Please sign in to comment.