Skip to content

Commit 7214841

Browse files
committed
refactor HashAt
1 parent b364e52 commit 7214841

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

testonly/tree.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,7 @@ func (t *Tree) Hash() []byte {
8282
// HashAt returns the root hash at the given size.
8383
// Requires 0 <= size <= Size(), otherwise panics.
8484
func (t *Tree) HashAt(size uint64) []byte {
85-
if size == 0 {
86-
return t.hasher.EmptyRoot()
87-
}
88-
hashes := t.getNodes(compact.RangeNodes(0, size, nil))
89-
90-
hash := hashes[len(hashes)-1]
91-
for i := len(hashes) - 2; i >= 0; i-- {
92-
hash = t.hasher.HashChildren(hashes[i], hash)
93-
}
94-
return hash
85+
return t.SubtreeHashAt(0, size)
9586
}
9687

9788
// SubtreeHashAt returns the root hash of the [start, end) subtree.

0 commit comments

Comments
 (0)