@@ -303,20 +303,21 @@ error::error_t CLASS::unspendable_prevout(const point_link& link,
303303}
304304
305305TEMPLATE
306- code CLASS::unspent_duplicates (const tx_link& coinbase ,
306+ code CLASS::unspent_duplicates (const header_link& link ,
307307 const context& ctx) const NOEXCEPT
308308{
309309 if (!ctx.is_enabled (system::chain::flags::bip30_rule))
310310 return error::success;
311311
312312 // This will be empty if current block is not set_strong.
313- const auto coinbases = to_strong_txs (get_tx_key (coinbase));
314- if (coinbases.empty ())
315- return error::integrity;
313+ const auto coinbases = to_strong_txs (get_tx_key (to_coinbase (link)));
316314
317315 if (is_one (coinbases.size ()))
318316 return error::success;
319317
318+ if (coinbases.empty ())
319+ return error::integrity;
320+
320321 // bip30: all (but self) must be confirmed spent or dup invalid (cb only).
321322 size_t unspent{};
322323 for (const auto & tx: coinbases)
@@ -327,6 +328,8 @@ code CLASS::unspent_duplicates(const tx_link& coinbase,
327328 return is_zero (unspent) ? error::integrity : error::success;
328329}
329330
331+ #if defined(UNDEFINED)
332+
330333// protected
331334TEMPLATE
332335spend_sets CLASS::to_spend_sets (const header_link& link) const NOEXCEPT
@@ -407,31 +410,27 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
407410 return ec;
408411}
409412
410- #if defined(UNDEFINED)
413+ #endif
414+
411415
412416// protected
413417TEMPLATE
414418spend_sets CLASS::to_spend_sets (const header_link& link) const NOEXCEPT
415419{
416- const auto txs = to_transactions (link);
420+ // Coinbase tx does not spend.
421+ const auto txs = to_spending_transactions (link);
422+
417423 if (txs.empty ())
418424 return {};
419425
420- // Coinbase optimization.
421426 spend_sets out{ txs.size () };
422- out.front ().tx = txs.front ();
423- if (is_one (out.size ()))
424- return out;
425-
426- const auto non_coinbase = std::next (txs.begin ());
427427 const auto to_set = [this ](const auto & tx) NOEXCEPT
428428 {
429429 return to_spend_set (tx);
430430 };
431431
432432 // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++.
433- std_transform (bc::par_unseq, std::next (txs.begin ()), txs.end (),
434- std::next (out.begin ()), to_set);
433+ std_transform (bc::par_unseq, txs.begin (), txs.end (), out.begin (), to_set);
435434
436435 return out;
437436}
@@ -444,16 +443,14 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
444443 if (!get_context (ctx, link))
445444 return error::integrity;
446445
447- // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++.
448- const auto sets = to_spend_sets (link);
449- if (sets.empty ())
450- return error::integrity;
451-
452446 code ec{};
453- if ((ec = unspent_duplicates (sets. front (). tx , ctx)))
447+ if ((ec = unspent_duplicates (link , ctx)))
454448 return ec;
455449
456- const auto non_coinbase = std::next (sets.begin ());
450+ const auto sets = to_spend_sets (link);
451+ if (sets.empty ())
452+ return ec;
453+
457454 std::atomic<error::error_t > fault{ error::success };
458455
459456 const auto is_unspendable = [this , &ctx, &fault](const auto & set) NOEXCEPT
@@ -484,16 +481,18 @@ code CLASS::block_confirmable(const header_link& link) const NOEXCEPT
484481 };
485482
486483 // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++.
487- if (std_any_of (bc::par_unseq, non_coinbase , sets.end (), is_unspendable))
484+ if (std_any_of (bc::par_unseq, sets. begin () , sets.end (), is_unspendable))
488485 return { fault.load () };
489486
490487 // C++17 incomplete on GCC/CLang, so presently parallel only on MSVC++.
491- if (std_any_of (bc::par_unseq, non_coinbase , sets.end (), is_spent))
488+ if (std_any_of (bc::par_unseq, sets. begin () , sets.end (), is_spent))
492489 return { fault.load () };
493-
490+
494491 return ec;
495492}
496493
494+ #if defined(UNDEFINED)
495+
497496// split(1) 446 secs for 400k-410k
498497TEMPLATE
499498code CLASS::block_confirmable (const header_link& link) const NOEXCEPT
@@ -620,7 +619,7 @@ TEMPLATE
620619bool CLASS::initialize (const block& genesis) NOEXCEPT
621620{
622621 BC_ASSERT (!is_initialized ());
623- BC_ASSERT (genesis.transactions_ptr ()->size () == one );
622+ BC_ASSERT (is_one ( genesis.transactions_ptr ()->size ()) );
624623
625624 // ========================================================================
626625 const auto scope = store_.get_transactor ();
0 commit comments