Skip to content

Commit 787c66e

Browse files
committed
Make unspendable() return code.
1 parent f708fca commit 787c66e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool CLASS::is_strong(const tx_link& tx) const NOEXCEPT
185185

186186
// protected
187187
TEMPLATE
188-
error::error_t CLASS::unspendable(uint32_t sequence, bool coinbase,
188+
code CLASS::unspendable(uint32_t sequence, bool coinbase,
189189
const tx_link& tx, uint32_t version, const context& ctx) const NOEXCEPT
190190
{
191191
// Ensure prevout tx is in a strong block, first try self link.
@@ -317,27 +317,27 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
317317

318318
// Get points for each tx, and sum the total number.
319319
std::transform(parallel, txs.begin(), txs.end(), sets.begin(), to_set);
320-
if (failure)
321-
return { failure.load() };
320+
if (failure != error::success)
321+
return failure.load();
322322

323323
// Check double spends strength, populates prevout parent tx/cb/sq links.
324324
if ((ec = populate_prevouts(sets, points, link)))
325325
return ec;
326326

327-
const auto is_unspendable = [this, &ctx, &failure](const auto& set) NOEXCEPT
327+
const auto is_spendable = [this, &ctx, &failure](const auto& set) NOEXCEPT
328328
{
329-
error::error_t ec{};
329+
code ec{};
330330
for (const auto& point: set.points)
331331
if (!point.tx.is_terminal() && ((ec = unspendable(point.sequence,
332332
point.coinbase, point.tx, set.version, ctx))))
333-
failure.store(ec);
333+
failure.store(static_cast<error::error_t>(ec.value()));
334334

335-
return failure != error::success;
335+
return failure == error::success;
336336
};
337337

338338
// Check all spends for spendability (strong, unlocked and mature).
339-
if (std::any_of(parallel, sets.begin(), sets.end(), is_unspendable))
340-
return { failure.load() };
339+
if (!std::all_of(parallel, sets.begin(), sets.end(), is_spendable))
340+
return failure.load();
341341

342342
return error::success;
343343
}

include/bitcoin/database/query.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ class query
652652
const context& ctx) const NOEXCEPT;
653653

654654
/// Called by block_confirmable (populate and check double spends).
655-
error::error_t unspendable(uint32_t sequence, bool coinbase,
655+
code unspendable(uint32_t sequence, bool coinbase,
656656
const tx_link& prevout_tx, uint32_t version,
657657
const context& ctx) const NOEXCEPT;
658658

0 commit comments

Comments
 (0)