Export types.rlpHash -> types.RLPHash

This is because one of its consumers (types.Header) will move out of
the types package.
pull/1498/head
Eugene Kim 5 years ago
parent b874e65126
commit cefa1d99cd
  1. 7
      core/types/block.go
  2. 2
      core/types/transaction.go
  3. 4
      core/types/transaction_signing.go

@ -113,7 +113,7 @@ type headerMarshaling struct {
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
// RLP encoding.
func (h *Header) Hash() common.Hash {
return rlpHash(h)
return RLPHash(h)
}
// Size returns the approximate memory used by all internal contents. It is used
@ -145,7 +145,8 @@ func (h *Header) GetShardState() (shard.ShardState, error) {
return shardState, nil
}
func rlpHash(x interface{}) (h common.Hash) {
// RLPHash hashes the RLP representation of the given object.
func RLPHash(x interface{}) (h common.Hash) {
hw := sha3.NewLegacyKeccak256()
rlp.Encode(hw, x)
hw.Sum(h[:0])
@ -453,7 +454,7 @@ func (c *writeCounter) Write(b []byte) (int, error) {
// CalcUncleHash returns rlp hash of uncles.
func CalcUncleHash(uncles []*Header) common.Hash {
return rlpHash(uncles)
return RLPHash(uncles)
}
// WithSeal returns a new block with the data from b but the header replaced with

@ -292,7 +292,7 @@ func (tx *Transaction) Hash() common.Hash {
if hash := tx.hash.Load(); hash != nil {
return hash.(common.Hash)
}
v := rlpHash(tx)
v := RLPHash(tx)
tx.hash.Store(v)
return v
}

@ -157,7 +157,7 @@ func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big
// Hash returns the hash to be signed by the sender.
// It does not uniquely identify the transaction.
func (s EIP155Signer) Hash(tx *Transaction) common.Hash {
return rlpHash([]interface{}{
return RLPHash([]interface{}{
tx.data.AccountNonce,
tx.data.Price,
tx.data.GasLimit,
@ -215,7 +215,7 @@ func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *
// Hash returns the hash to be signed by the sender.
// It does not uniquely identify the transaction.
func (fs FrontierSigner) Hash(tx *Transaction) common.Hash {
return rlpHash([]interface{}{
return RLPHash([]interface{}{
tx.data.AccountNonce,
tx.data.Price,
tx.data.GasLimit,

Loading…
Cancel
Save