Skip to content

Commit 68be45e

Browse files
crackcommkaralabe
authored andcommitted
trie: return hasher to pool (#18116)
* trie: return hasher to pool * trie: minor code formatting fix
1 parent ffe2fc3 commit 68be45e

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎trie/iterator.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ func (it *nodeIterator) LeafProof() [][]byte {
181181
if len(it.stack) > 0 {
182182
if _, ok := it.stack[len(it.stack)-1].node.(valueNode); ok {
183183
hasher := newHasher(0, 0, nil)
184+
defer returnHasherToPool(hasher)
185+
184186
proofs := make([][]byte, 0, len(it.stack))
185187

186188
for i, item := range it.stack[:len(it.stack)-1] {

‎trie/proof.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.Putter) error {
6666
}
6767
}
6868
hasher := newHasher(0, 0, nil)
69+
defer returnHasherToPool(hasher)
70+
6971
for i, n := range nodes {
7072
// Don't bother checking for errors here since hasher panics
7173
// if encoding doesn't work and we're not writing to any database.

0 commit comments

Comments
 (0)