Skip to content

Commit f8da59c

Browse files
committed
Bypass populate for empty blocks.
1 parent b0629d2 commit f8da59c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/chain/block.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,17 +704,22 @@ bool block::is_unspent_coinbase_collision() const NOEXCEPT
704704
// Search is not ordered, forward references are caught by block.check.
705705
bool block::populate() const NOEXCEPT
706706
{
707-
uint32_t index{};
707+
if (txs_->empty())
708+
return true;
709+
708710
unordered_map_of_cref_point_to_output_cptr_cref points{};
711+
const auto second = std::next(txs_->begin());
712+
const auto last = txs_->end();
713+
uint32_t index{};
709714

710715
// Populate outputs hash table.
711-
for (auto tx = txs_->begin(); tx != txs_->end(); ++tx, index = 0)
716+
for (auto tx = second; tx != last; ++tx, index = 0)
712717
for (const auto& out: *(*tx)->outputs_ptr())
713718
points.emplace(cref_point{ (*tx)->get_hash(false), index++ }, out);
714719

715720
// Populate input prevouts from hash table and obtain locked state.
716721
auto locked = false;
717-
for (auto tx = txs_->begin(); tx != txs_->end(); ++tx)
722+
for (auto tx = second; tx != last; ++tx)
718723
{
719724
for (const auto& in: *(*tx)->inputs_ptr())
720725
{

0 commit comments

Comments
 (0)