File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -229,12 +229,11 @@ const transactions_cptr& block::transactions_ptr() const NOEXCEPT
229229
230230hashes block::transaction_hashes (bool witness) const NOEXCEPT
231231{
232+ // Extra allocation for odd count optimizes for merkle root.
233+ // Vector capacity is never reduced when resizing to smaller size.
232234 const auto count = txs_->size ();
233235 const auto size = is_odd (count) && count > one ? add1 (count) : count;
234236 hashes out (size);
235-
236- // Extra allocation for odd count optimizes for merkle root.
237- // Vector capacity is never reduced when resizing to smaller size.
238237 out.resize (count);
239238
240239 const auto hash = [witness](const auto & tx) NOEXCEPT
@@ -449,10 +448,9 @@ bool block::is_invalid_merkle_root() const NOEXCEPT
449448block::positions block::merkle_branch (size_t leaf, size_t leaves) NOEXCEPT
450449{
451450 BC_ASSERT (leaves <= power2 (sub1 (bits<size_t >)));
452- BC_ASSERT (leaf < leaves);
453451
454452 positions branch{};
455- if (is_zero (leaves))
453+ if (is_zero (leaves) || leaf >= leaves )
456454 return branch;
457455
458456 // Upper bound, actual count may be less due to duplication.
You can’t perform that action at this time.
0 commit comments