aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGus <yo@soygus.com>2019-01-29 17:17:40 +0800
committerFelix Lange <fjl@users.noreply.github.com>2019-01-29 17:17:40 +0800
commit4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd (patch)
tree7f770dce1671e787c808c99af90cfb246890e16c
parent21acf0bc8d4f179397bb7d06d6f36df3cbee4a8e (diff)
downloadgo-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar.gz
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar.bz2
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar.lz
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar.xz
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.tar.zst
go-tangerine-4eee99aac5d890602a8dc8c5b8ff55670bb2d1fd.zip
core/types: remove use of package unsafe
-rw-r--r--core/types/block.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/types/block.go b/core/types/block.go
index 57905d8c7..b84e13c65 100644
--- a/core/types/block.go
+++ b/core/types/block.go
@@ -21,10 +21,10 @@ import (
"encoding/binary"
"io"
"math/big"
+ "reflect"
"sort"
"sync/atomic"
"time"
- "unsafe"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
@@ -102,10 +102,12 @@ func (h *Header) Hash() common.Hash {
return rlpHash(h)
}
+var headerSize = common.StorageSize(reflect.TypeOf(Header{}).Size())
+
// 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)
+ return headerSize + common.StorageSize(len(h.Extra)+(h.Difficulty.BitLen()+h.Number.BitLen()+h.Time.BitLen())/8)
}
func rlpHash(x interface{}) (h common.Hash) {