erigon-pulse/crypto/cryptopool/pool.go

23 lines
374 B
Go
Raw Normal View History

2022-12-04 04:59:02 +00:00
package cryptopool
import (
"hash"
"sync"
"golang.org/x/crypto/sha3"
)
// hasherPool holds LegacyKeccak hashers.
var hasherPool = sync.Pool{
New: func() interface{} {
return sha3.NewLegacyKeccak256()
},
}
func NewLegacyKeccak256() hash.Hash {
h := hasherPool.Get().(hash.Hash)
h.Reset()
return h
}
func ReturnToPoolKeccak256(h hash.Hash) { hasherPool.Put(h) }