diff --git a/core/types/block.go b/core/types/block.go index 8a21bba1e7..28b1c13293 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -110,7 +110,16 @@ func (h *Header) Size() common.StorageSize { func rlpHash(x interface{}) (h common.Hash) { hw := sha3.NewKeccak256() - rlp.Encode(hw, x) + err := rlp.Encode(hw, x) + if err != nil { + panic("encode error: " + err.Error()) + } + hw.Sum(h[:0]) + return h +} + +func hash(x interface{}) (h common.Hash) { + hw := sha3.NewKeccak256() hw.Sum(h[:0]) return h } @@ -325,7 +334,7 @@ func (c *writeCounter) Write(b []byte) (int, error) { } func CalcUncleHash(uncles []*Header) common.Hash { - return rlpHash(uncles) + return hash(uncles) } // WithSeal returns a new block with the data from b but the header replaced with