Skip to content

Commit 88a85df

Browse files
authored
Merge pull request #739 from evoskuil/master
Overallocate get_tx_keys for common merkle scenario.
2 parents aee5fb6 + 7d072e6 commit 88a85df

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,12 @@ hashes CLASS::get_tx_keys(const header_link& link) const NOEXCEPT
112112
if (tx_fks.empty())
113113
return {};
114114

115+
// Overallocate as required for the common merkle scenario.
116+
const auto count = tx_fks.size();
117+
const auto size = is_odd(count) && !is_one(count) ? add1(count) : count;
118+
115119
system::hashes hashes{};
116-
hashes.reserve(tx_fks.size());
120+
hashes.reserve(size);
117121
for (const auto& tx_fk: tx_fks)
118122
hashes.push_back(get_tx_key(tx_fk));
119123

0 commit comments

Comments
 (0)