Skip to content

Commit

Permalink
Merge pull request #1580 from 0chain/hotfix/vt-finalize
Browse files Browse the repository at this point in the history
check leaf index in finalize
  • Loading branch information
dabasov authored Aug 16, 2024
2 parents 9830d99 + 94877b5 commit 95591c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/util/validation_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func (v *ValidationTree) Finalize() error {
v.isFinalized = true

if v.writeCount > 0 {
if v.leafIndex == len(v.leaves) {
// increase leaves size
leaves := make([][]byte, len(v.leaves)+1)
copy(leaves, v.leaves)
v.leaves = leaves
}
v.leaves[v.leafIndex] = v.h.Sum(nil)
} else {
v.leafIndex--
Expand Down

0 comments on commit 95591c8

Please sign in to comment.