@@ -139,7 +139,7 @@ void block::assign_data(reader& source, bool witness) NOEXCEPT
139139 auto txs = to_non_const_raw_ptr (txs_);
140140 txs->reserve (count);
141141
142- for (size_t tx = 0 ; tx < count; ++tx)
142+ for (size_t tx{} ; tx < count; ++tx)
143143 txs->emplace_back (CREATE (transaction, allocator, source, witness));
144144
145145 size_ = serialized_size (*txs_);
@@ -750,20 +750,6 @@ bool block::is_signature_operations_limited(bool bip16,
750750 return signature_operations (bip16, bip141) > limit;
751751}
752752
753- // *****************************************************************************
754- // CONSENSUS: check excluded under bip30 exception blocks and bip30_deactivate
755- // until bip30_reactivate. Those conditions are rolled up into the bip30 flag.
756- // *****************************************************************************
757- bool block::is_unspent_coinbase_collision () const NOEXCEPT
758- {
759- if (txs_->empty () || txs_->front ()->inputs_ptr ()->empty ())
760- return false ;
761-
762- // May only commit duplicate coinbase that is already confirmed spent.
763- // Metadata population defaults coinbase to spent (not a collision).
764- return !txs_->front ()->inputs_ptr ()->front ()->metadata .spent ;
765- }
766-
767753// Search is unordered, forward refs (and duplicates) caught by block.check.
768754void block::populate () const NOEXCEPT
769755{
@@ -798,6 +784,8 @@ code block::populate_with_metadata(const chain::context& ctx) const NOEXCEPT
798784 if (txs_->empty ())
799785 return error::block_success;
800786
787+ const auto & self = txs_->front ()->get_hash (false );
788+ constexpr auto matures = !is_zero (coinbase_maturity);
801789 const auto bip68 = ctx.is_enabled (chain::flags::bip68_rule);
802790 unordered_map_of_cref_point_to_output_cptr_cref points (outputs ());
803791 uint32_t index{};
@@ -807,27 +795,24 @@ code block::populate_with_metadata(const chain::context& ctx) const NOEXCEPT
807795 for (const auto & out: *(*tx)->outputs_ptr ())
808796 points.emplace (cref_point{ (*tx)->get_hash (false ), index++ }, out);
809797
810- // Populate input prevouts from hash table and obtain maturity.
798+ // Populate prevouts from hash table, determine get locked and maturity.
811799 for (auto tx = std::next (txs_->begin ()); tx != txs_->end (); ++tx)
812800 {
813801 for (const auto & in: *(*tx)->inputs_ptr ())
814802 {
815803 // Map chain::point to cref_point for search, should optimize away.
816- const auto point = points.find ({ in->point ().hash (),
817- in->point ().index () });
804+ const cref_point key{ in->point ().hash (), in->point ().index () };
818805
819- if (point != points.end ())
806+ if (const auto it = points. find (key); it != points.end ())
820807 {
821- // Zero maturity coinbase spend is immature.
808+ const auto immature = (matures && in-> point (). hash () == self);
822809 const auto lock = (bip68 && (*tx)->is_internally_locked (*in));
823- const auto immature = !is_zero (coinbase_maturity) &&
824- (in->point ().hash () == txs_->front ()->get_hash (false ));
810+ in->prevout = it->second ;
825811
826- in-> prevout = point-> second ;
812+ // If invalid shortcircuit population and return above error.
827813 if ((in->metadata .locked = (immature || lock)))
828814 {
829- // Shortcircuit population and return above error.
830- return immature ? error::coinbase_maturity :
815+ return immature ? error::coinbase_maturity :
831816 error::relative_time_locked;
832817 }
833818 }
@@ -996,11 +981,6 @@ code block::accept(const context& ctx, size_t subsidy_interval,
996981// This assumes that prevout and metadata caching are completed on all inputs.
997982code block::confirm (const context& ctx) const NOEXCEPT
998983{
999- const auto bip30 = ctx.is_enabled (bip30_rule);
1000-
1001- if (bip30 && is_unspent_coinbase_collision ())
1002- return error::unspent_coinbase_collision;
1003-
1004984 return confirm_transactions (ctx);
1005985}
1006986
0 commit comments