diff options
author | Łukasz Kurowski <crackcomm@users.noreply.github.com> | 2018-11-16 17:50:48 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-11-16 17:50:48 +0800 |
commit | 68be45e5f89a5bde33376a8e103c133392f18516 (patch) | |
tree | a5242ad110afd6c168347e798191746ad8553b6f | |
parent | ffe2fc3bc4d77ad3f503d2bc1cdd62eac8d03c5b (diff) | |
download | dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar.gz dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar.bz2 dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar.lz dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar.xz dexon-68be45e5f89a5bde33376a8e103c133392f18516.tar.zst dexon-68be45e5f89a5bde33376a8e103c133392f18516.zip |
trie: return hasher to pool (#18116)
* trie: return hasher to pool
* trie: minor code formatting fix
-rw-r--r-- | trie/iterator.go | 2 | ||||
-rw-r--r-- | trie/proof.go | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/trie/iterator.go b/trie/iterator.go index 00b890eb8..77f168166 100644 --- a/trie/iterator.go +++ b/trie/iterator.go @@ -181,6 +181,8 @@ func (it *nodeIterator) LeafProof() [][]byte { if len(it.stack) > 0 { if _, ok := it.stack[len(it.stack)-1].node.(valueNode); ok { hasher := newHasher(0, 0, nil) + defer returnHasherToPool(hasher) + proofs := make([][]byte, 0, len(it.stack)) for i, item := range it.stack[:len(it.stack)-1] { diff --git a/trie/proof.go b/trie/proof.go index 6cb8f4d5f..62c47beda 100644 --- a/trie/proof.go +++ b/trie/proof.go @@ -66,6 +66,8 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.Putter) error { } } hasher := newHasher(0, 0, nil) + defer returnHasherToPool(hasher) + for i, n := range nodes { // Don't bother checking for errors here since hasher panics // if encoding doesn't work and we're not writing to any database. |