account: remove redundant string conversion when using %s to format []byte to save unnecessary overhead

Signed-off-by: cuinix <915115094@qq.com>
This commit is contained in:
cuinix 2024-03-07 10:56:43 +08:00
parent aadcb88675
commit 404c234c47

View file

@ -195,7 +195,7 @@ func TextHash(data []byte) []byte {
//
// This gives context to the signed message and prevents signing of transactions.
func TextAndHash(data []byte) ([]byte, string) {
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data)
hasher := sha3.NewLegacyKeccak256()
hasher.Write([]byte(msg))
return hasher.Sum(nil), msg