erigon-pulse/crypto/cryptopool/pool.go
2022-12-04 11:59:02 +07:00

23 lines
374 B
Go

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) }