github.com/ledgerwatch/erigon-lib@v1.0.0/crypto/cryptopool/pool.go (about)

     1  package cryptopool
     2  
     3  import (
     4  	"hash"
     5  	"sync"
     6  
     7  	"golang.org/x/crypto/sha3"
     8  )
     9  
    10  var pool = sync.Pool{
    11  	New: func() interface{} {
    12  		return sha3.NewLegacyKeccak256()
    13  	},
    14  }
    15  
    16  func GetLegacyKeccak256() hash.Hash {
    17  	h := pool.Get().(hash.Hash)
    18  	h.Reset()
    19  	return h
    20  }
    21  func ReturnLegacyKeccak256(h hash.Hash) { pool.Put(h) }