From be3865211c2d8f71e0733b17c469881502e89371 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 9 Nov 2016 01:20:49 +0100 Subject: core/types: remove header accessors These accessors were introduced by light client changes, but the only method that is actually used is GetNumberU64. This commit replaces all uses of .GetNumberU64 with .Number.Uint64. --- core/database_util.go | 12 ++++++------ core/types/block.go | 9 --------- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'core') diff --git a/core/database_util.go b/core/database_util.go index 73fac20aa..0fb593554 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -632,24 +632,24 @@ func GetChainConfig(db ethdb.Database, hash common.Hash) (*ChainConfig, error) { // FindCommonAncestor returns the last common ancestor of two block headers func FindCommonAncestor(db ethdb.Database, a, b *types.Header) *types.Header { - for a.GetNumberU64() > b.GetNumberU64() { - a = GetHeader(db, a.ParentHash, a.GetNumberU64()-1) + for bn := b.Number.Uint64(); a.Number.Uint64() > bn; { + a = GetHeader(db, a.ParentHash, a.Number.Uint64()-1) if a == nil { return nil } } - for a.GetNumberU64() < b.GetNumberU64() { - b = GetHeader(db, b.ParentHash, b.GetNumberU64()-1) + for an := a.Number.Uint64(); an < b.Number.Uint64(); { + b = GetHeader(db, b.ParentHash, b.Number.Uint64()-1) if b == nil { return nil } } for a.Hash() != b.Hash() { - a = GetHeader(db, a.ParentHash, a.GetNumberU64()-1) + a = GetHeader(db, a.ParentHash, a.Number.Uint64()-1) if a == nil { return nil } - b = GetHeader(db, b.ParentHash, b.GetNumberU64()-1) + b = GetHeader(db, b.ParentHash, b.Number.Uint64()-1) if b == nil { return nil } diff --git a/core/types/block.go b/core/types/block.go index 4accb0ee3..fedcfdbbe 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -116,15 +116,6 @@ type jsonHeader struct { Nonce *BlockNonce `json:"nonce"` } -func (h *Header) GetNumber() *big.Int { return new(big.Int).Set(h.Number) } -func (h *Header) GetGasLimit() *big.Int { return new(big.Int).Set(h.GasLimit) } -func (h *Header) GetGasUsed() *big.Int { return new(big.Int).Set(h.GasUsed) } -func (h *Header) GetDifficulty() *big.Int { return new(big.Int).Set(h.Difficulty) } -func (h *Header) GetTime() *big.Int { return new(big.Int).Set(h.Time) } -func (h *Header) GetNumberU64() uint64 { return h.Number.Uint64() } -func (h *Header) GetNonce() uint64 { return binary.BigEndian.Uint64(h.Nonce[:]) } -func (h *Header) GetExtra() []byte { return common.CopyBytes(h.Extra) } - // Hash returns the block hash of the header, which is simply the keccak256 hash of its // RLP encoding. func (h *Header) Hash() common.Hash { -- cgit v1.2.3