Skip to content

Instantly share code, notes, and snippets.

@fcecin
Created January 16, 2025 14:54
Show Gist options
  • Save fcecin/2fe336e9f76900f37be89a35e5ebac62 to your computer and use it in GitHub Desktop.
Save fcecin/2fe336e9f76900f37be89a35e5ebac62 to your computer and use it in GitHub Desktop.
* types/tx.go:
** No import(...) no topo do arquivo, adicionar:
"github.com/ethereum/go-ethereum/crypto"
** E logo abaixo:
// Hash computes the TMHASH hash of the wire encoded transaction.
//
// func (tx Tx) Hash() []byte {
// return tmhash.Sum(tx)
// }
func (tx Tx) Hash() []byte {
return crypto.Keccak256(tx)
}
// func (tx Tx) Key() TxKey {
// return sha256.Sum256(tx)
// }
//
// Key returns the Keccak256-based fixed-length key for indexing.
func (tx Tx) Key() TxKey {
var key TxKey
copy(key[:], crypto.Keccak256(tx))
return key
}
* go.mod:
** Adicionar no primeiro grupo de require(...):
github.com/ethereum/go-ethereum v1.14.12
** Ir no cmd line e digitar:
go mod tidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment