Skip to content

Commit 2ee1064

Browse files
committed
Comments, move assertion to full guard.
1 parent 6a11b17 commit 2ee1064

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/chain/block.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,11 @@ const transactions_cptr& block::transactions_ptr() const NOEXCEPT
229229

230230
hashes 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
449448
block::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.

0 commit comments

Comments
 (0)