mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
23 lines
374 B
Go
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) }
|