diff --git a/core/types/block.go b/core/types/block.go index 8a21bba1e7..9ea3c9f128 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -24,7 +24,6 @@ import ( "sort" "sync/atomic" "time" - "unsafe" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -105,7 +104,8 @@ func (h *Header) Hash() common.Hash { // Size returns the approximate memory used by all internal contents. It is used // to approximate and limit the memory consumption of various caches. func (h *Header) Size() common.StorageSize { - return common.StorageSize(unsafe.Sizeof(*h)) + common.StorageSize(len(h.Extra)+(h.Difficulty.BitLen()+h.Number.BitLen()+h.Time.BitLen())/8) + size := binary.Size(h) + return common.StorageSize(size) + common.StorageSize(len(h.Extra)+(h.Difficulty.BitLen()+h.Number.BitLen()+h.Time.BitLen())/8) } func rlpHash(x interface{}) (h common.Hash) {