Skip to content

Commit

Permalink
Merge pull request #286 from kcalvinalvin/2025-03-05-getutreexosummar…
Browse files Browse the repository at this point in the history
…yheights-bug-fix

wire: fix bug in GetUtreexoSummaryHeights
  • Loading branch information
kcalvinalvin authored Mar 5, 2025
2 parents 67c1607 + aecf8fc commit 842c177
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions wire/msggetutreexosummaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,18 @@ func GetUtreexoSummaryHeights(startBlock, bestHeight int32, exponent uint8) ([]i
count := int32(1 << exponent)
numLeaves := uint64(bestHeight + 1)

endPos := startBlock + count
if endPos > bestHeight {
endPos = bestHeight
}

subtree, _, _, _ := utreexo.DetectOffset(uint64(startBlock), numLeaves)
heights := make([]int32, 0, count)
for i := startBlock; i <= endPos; i++ {
got, _, _, _ := utreexo.DetectOffset(uint64(i), numLeaves)
for i := int32(0); i < count; i++ {
position := i + startBlock
if position > bestHeight {
break
}
got, _, _, _ := utreexo.DetectOffset(uint64(position), numLeaves)
if got != subtree {
break
}
heights = append(heights, i)
heights = append(heights, position)
}

return heights, nil
Expand Down

0 comments on commit 842c177

Please sign in to comment.