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. --- les/fetcher.go | 4 ++-- les/odr_test.go | 2 +- les/request_test.go | 4 ++-- les/server.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'les') diff --git a/les/fetcher.go b/les/fetcher.go index 3fa5cf0e2..d93b7db37 100644 --- a/les/fetcher.go +++ b/les/fetcher.go @@ -103,7 +103,7 @@ func (f *lightFetcher) gotHeader(header *types.Header) { if peerList == nil { return } - number := header.GetNumberU64() + number := header.Number.Uint64() td := core.GetTd(f.pm.chainDb, hash, number) for _, peer := range peerList { peer.lock.Lock() @@ -201,7 +201,7 @@ func (f *lightFetcher) processResponse(req fetchRequest, resp fetchResponse) boo return false } for _, header := range headers { - td := core.GetTd(f.pm.chainDb, header.Hash(), header.GetNumberU64()) + td := core.GetTd(f.pm.chainDb, header.Hash(), header.Number.Uint64()) if td == nil { return false } diff --git a/les/odr_test.go b/les/odr_test.go index bd52a82dd..cdf62464b 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -193,7 +193,7 @@ func testOdr(t *testing.T, protocol int, expFail uint64, fn odrTestFn) { lpm.synchronise(lpeer) test := func(expFail uint64) { - for i := uint64(0); i <= pm.blockchain.CurrentHeader().GetNumberU64(); i++ { + for i := uint64(0); i <= pm.blockchain.CurrentHeader().Number.Uint64(); i++ { bhash := core.GetCanonicalHash(db, i) b1 := fn(light.NoOdr, db, pm.chainConfig, pm.blockchain.(*core.BlockChain), nil, bhash) ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond) diff --git a/les/request_test.go b/les/request_test.go index df02afb32..77788d4a9 100644 --- a/les/request_test.go +++ b/les/request_test.go @@ -42,7 +42,7 @@ func TestCodeAccessLes1(t *testing.T) { testAccess(t, 1, tfCodeAccess) } func tfCodeAccess(db ethdb.Database, bhash common.Hash, number uint64) light.OdrRequest { header := core.GetHeader(db, bhash, core.GetBlockNumber(db, bhash)) - if header.GetNumberU64() < testContractDeployed { + if header.Number.Uint64() < testContractDeployed { return nil } sti := light.StateTrieID(header) @@ -66,7 +66,7 @@ func testAccess(t *testing.T, protocol int, fn accessTestFn) { lpm.synchronise(lpeer) test := func(expFail uint64) { - for i := uint64(0); i <= pm.blockchain.CurrentHeader().GetNumberU64(); i++ { + for i := uint64(0); i <= pm.blockchain.CurrentHeader().Number.Uint64(); i++ { bhash := core.GetCanonicalHash(db, i) if req := fn(ldb, bhash, i); req != nil { ctx, _ := context.WithTimeout(context.Background(), 200*time.Millisecond) diff --git a/les/server.go b/les/server.go index 874586a7e..0f0e2db42 100644 --- a/les/server.go +++ b/les/server.go @@ -279,12 +279,12 @@ func (pm *ProtocolManager) blockLoop() { if len(peers) > 0 { header := ev.Data.(core.ChainHeadEvent).Block.Header() hash := header.Hash() - number := header.GetNumberU64() + number := header.Number.Uint64() td := core.GetTd(pm.chainDb, hash, number) if td != nil && td.Cmp(lastBroadcastTd) > 0 { var reorg uint64 if lastHead != nil { - reorg = lastHead.GetNumberU64() - core.FindCommonAncestor(pm.chainDb, header, lastHead).GetNumberU64() + reorg = lastHead.Number.Uint64() - core.FindCommonAncestor(pm.chainDb, header, lastHead).Number.Uint64() } lastHead = header lastBroadcastTd = td -- cgit v1.2.3