Skip to content

Commit 420ede4

Browse files
committed
Add counter to block.populate().
1 parent fa79f7c commit 420ede4

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

include/bitcoin/system/chain/block.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class BC_API block
137137
code confirm(const context& ctx) const NOEXCEPT;
138138

139139
/// Populate previous outputs (only, no metadata) internal to the block.
140-
void populate() const NOEXCEPT;
140+
size_t populate() const NOEXCEPT;
141141

142142
protected:
143143
block(const chain::header::cptr& header,

src/chain/block.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ bool block::is_unspent_coinbase_collision() const NOEXCEPT
688688
}
689689

690690
// Search is not ordered, forward references are caught by block.check.
691-
void block::populate() const NOEXCEPT
691+
size_t block::populate() const NOEXCEPT
692692
{
693693
std::unordered_map<point, output::cptr> points{};
694694
uint32_t index{};
@@ -699,16 +699,22 @@ void block::populate() const NOEXCEPT
699699
points.emplace(std::pair{ point{ (*tx)->hash(false), index++ },
700700
out });
701701

702-
// Populate input prevouts from hash table.
702+
// Populate input prevouts from hash table and obtain count.
703+
size_t count{};
703704
for (auto tx = txs_->begin(); tx != txs_->end(); ++tx)
704705
{
705706
for (const auto& in: *(*tx)->inputs_ptr())
706707
{
707708
const auto point = points.find(in->point());
708709
if (point != points.end())
710+
{
711+
++count;
709712
in->prevout = point->second;
713+
}
710714
}
711715
}
716+
717+
return count;
712718
}
713719

714720
// Delegated.

0 commit comments

Comments
 (0)