trie: make fullnode children hash calculation concurrently (#15131)

* trie: make fullnode children hash calculation concurrently

* trie: thread out only on topmost fullnode

* trie: clean up full node children hash calculation

* trie: minor code fixups
This commit is contained in:
gary rong
2017-11-27 19:34:17 +08:00
committed by Péter Szilágyi
parent e4c9fd29a3
commit 0f7fbb85d6
3 changed files with 88 additions and 32 deletions

View File

@@ -199,10 +199,10 @@ func (t *SecureTrie) secKey(key []byte) []byte {
// invalid on the next call to hashKey or secKey.
func (t *SecureTrie) hashKey(key []byte) []byte {
h := newHasher(0, 0)
h.sha.Reset()
h.sha.Write(key)
buf := h.sha.Sum(t.hashKeyBuf[:0])
returnHasherToPool(h)
calculator := h.newCalculator()
calculator.sha.Write(key)
buf := calculator.sha.Sum(t.hashKeyBuf[:0])
h.returnCalculator(calculator)
return buf
}