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.
This commit is contained in:
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user