crypto: less allocations when hashing and tx handling (#21265)

This commit is contained in:
Daniel Liu 2024-11-29 16:08:31 +08:00
parent ee303c9f3d
commit f948466976

View file

@ -75,7 +75,7 @@ func HashData(kh KeccakState, data []byte) (h common.Hash) {
// Keccak256 calculates and returns the Keccak256 hash of the input data.
func Keccak256(data ...[]byte) []byte {
b := make([]byte, 32)
d := NewKeccakState()
d := sha3.NewLegacyKeccak256().(KeccakState)
for _, b := range data {
d.Write(b)
}
@ -86,7 +86,7 @@ func Keccak256(data ...[]byte) []byte {
// Keccak256Hash calculates and returns the Keccak256 hash of the input data,
// converting it to an internal Hash data structure.
func Keccak256Hash(data ...[]byte) (h common.Hash) {
d := NewKeccakState()
d := sha3.NewLegacyKeccak256().(KeccakState)
for _, b := range data {
d.Write(b)
}