Skip to content

Commit d7e3399

Browse files
committed
Revert integrity differentiation, don't pass rvalue to it().
1 parent 24f2c4c commit d7e3399

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

include/bitcoin/database/error.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ enum error_t : uint8_t
3737
success,
3838
unknown_state,
3939
integrity,
40-
integrity1,
41-
integrity2,
42-
integrity3,
43-
integrity4,
4440

4541
/// memory map
4642
open_open,

include/bitcoin/database/impl/query/confirm.ipp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,22 +283,26 @@ error::error_t CLASS::spent_prevout(const point_link& link, index index,
283283
// The upside is half the prevout size (read/write/page) and store increase.
284284

285285
// Iterate points by point hash (of output tx) because may be conflicts.
286-
auto point = store_.point.it(get_point_key(link));
286+
// Search key must be passed as an l-value as it is held by reference.
287+
const auto point_sk = get_point_key(link);
288+
auto point = store_.point.it(point_sk);
287289
if (!point)
288-
return error::integrity1;
290+
return error::integrity;
289291

290292
do
291293
{
292294
// Iterate all spends of the point to find double spends.
293-
auto it = store_.spend.it(table::spend::compose(point.self(), index));
295+
// Search key must be passed as an l-value as it is held by reference.
296+
const auto spend_sk = table::spend::compose(point.self(), index);
297+
auto it = store_.spend.it(spend_sk);
294298
if (!it)
295299
return error::success;
296300

297301
table::spend::get_parent spend{};
298302
do
299303
{
300304
if (!store_.spend.get(it, spend))
301-
return error::integrity2;
305+
return error::integrity;
302306

303307
// is_strong_tx (search) only called in the case of duplicate.
304308
// Other parent tx of spend is strong (confirmed spent prevout).
@@ -359,7 +363,7 @@ error::error_t CLASS::unspendable_prevout(uint32_t sequence, bool coinbase,
359363

360364
context out{};
361365
if (!get_context(out, block))
362-
return error::integrity3;
366+
return error::integrity;
363367

364368
// All txs with same hash must be coinbase or not.
365369
if (coinbase && !transaction::is_coinbase_mature(out.height, ctx.height))
@@ -494,12 +498,14 @@ spend_sets CLASS::to_spend_sets(const header_link& link) const NOEXCEPT
494498
// Coinbase tx does not spend so is not retrieved.
495499
const auto txs = to_spending_transactions(link);
496500

501+
// Empty here is normal.
497502
if (txs.empty())
498503
return {};
499504

500505
spend_sets sets{ txs.size() };
501506
const auto to_set = [this](const auto& tx) NOEXCEPT
502507
{
508+
// Empty here implies integrity fault.
503509
return to_spend_set(tx);
504510
};
505511

@@ -533,13 +539,14 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
533539
{
534540
context ctx{};
535541
if (!get_context(ctx, link))
536-
return error::integrity4;
542+
return error::integrity;
537543

538544
// This is never invoked (bip30).
539545
code ec{};
540546
if ((ec = unspent_duplicates(link, ctx)))
541547
return ec;
542548

549+
// Empty here could imply integrity fault.
543550
const auto sets = to_spend_sets(link);
544551
if (sets.empty())
545552
return ec;
@@ -753,6 +760,8 @@ bool CLASS::initialize(const block& genesis) NOEXCEPT
753760
BC_ASSERT(!is_initialized());
754761
BC_ASSERT(is_one(genesis.transactions_ptr()->size()));
755762

763+
// TODO: add genesis block neutrino head and body when neutrino is enabled.
764+
756765
// ========================================================================
757766
const auto scope = store_.get_transactor();
758767

include/bitcoin/database/query.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,14 @@ class query
543543
bool set_filter_head(const header_link& link,
544544
const hash_digest& head) NOEXCEPT;
545545

546+
// TODO: protected
547+
spend_set to_spend_set(const tx_link& link) const NOEXCEPT;
548+
spend_sets to_spend_sets(const header_link& link) const NOEXCEPT;
549+
546550
protected:
547551
/// Translate.
548552
/// -----------------------------------------------------------------------
549553

550-
spend_set to_spend_set(const tx_link& link) const NOEXCEPT;
551-
spend_sets to_spend_sets(const header_link& link) const NOEXCEPT;
552-
553554
uint32_t to_spend_index(const tx_link& parent_fk,
554555
const spend_link& input_fk) const NOEXCEPT;
555556
uint32_t to_output_index(const tx_link& parent_fk,

src/error.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ DEFINE_ERROR_T_MESSAGE_MAP(error)
3030
{ success, "success" },
3131
{ unknown_state, "unknown state" },
3232
{ integrity, "store corrupted" },
33-
{ integrity1, "store corrupted1" },
34-
{ integrity2, "store corrupted2" },
35-
{ integrity3, "store corrupted3" },
36-
{ integrity4, "store corrupted4" },
3733

3834
// memory map
3935
{ open_open, "opening open file" },

test/query/confirm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__bad_link__integrity)
469469
BOOST_REQUIRE_EQUAL(store.create(events_handler), error::success);
470470
BOOST_REQUIRE(query.initialize(test::genesis));
471471
BOOST_REQUIRE(query.set(test::block1, context{ bip68, 1, 0 }, false, false));
472-
BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::integrity4);
472+
BOOST_REQUIRE_EQUAL(query.block_confirmable(2), error::integrity);
473473
}
474474

475475
BOOST_AUTO_TEST_CASE(query_confirm__block_confirmable__null_points__success)

0 commit comments

Comments
 (0)