@@ -3,6 +3,7 @@ import { Synchronizer, SynchronizerOptions } from './sync'
3
3
import { HeaderFetcher } from './fetcher/headerfetcher'
4
4
import { BN } from 'ethereumjs-util'
5
5
import { short } from '../util'
6
+ import { BlockHeader } from '@ethereumjs/block'
6
7
7
8
/**
8
9
* Implements an ethereum light sync synchronizer
@@ -44,7 +45,7 @@ export class LightSynchronizer extends Synchronizer {
44
45
if ( peer . les ) {
45
46
const td = peer . les . status . headTd
46
47
if (
47
- ( ! best && td . gte ( ( this . chain . headers as any ) . td ) ) ||
48
+ ( ! best && td . gte ( this . chain . headers . td ) ) ||
48
49
( best && best . les && best . les . status . headTd . lt ( td ) )
49
50
) {
50
51
best = peer
@@ -62,7 +63,7 @@ export class LightSynchronizer extends Synchronizer {
62
63
async syncWithPeer ( peer ?: Peer ) : Promise < boolean > {
63
64
if ( ! peer ) return false
64
65
const height = new BN ( peer . les ! . status . headNum )
65
- const first = ( ( this . chain . headers as any ) . height as BN ) . addn ( 1 )
66
+ const first = this . chain . headers . height . addn ( 1 )
66
67
const count = height . sub ( first ) . addn ( 1 )
67
68
if ( count . lten ( 0 ) ) return false
68
69
@@ -83,7 +84,7 @@ export class LightSynchronizer extends Synchronizer {
83
84
. on ( 'error' , ( error : Error ) => {
84
85
this . emit ( 'error' , error )
85
86
} )
86
- . on ( 'fetched' , ( headers : any [ ] ) => {
87
+ . on ( 'fetched' , ( headers : BlockHeader [ ] ) => {
87
88
const first = new BN ( headers [ 0 ] . number )
88
89
const hash = short ( headers [ 0 ] . hash ( ) )
89
90
this . config . logger . info (
@@ -114,9 +115,9 @@ export class LightSynchronizer extends Synchronizer {
114
115
async open ( ) : Promise < void > {
115
116
await this . chain . open ( )
116
117
await this . pool . open ( )
117
- const number = ( ( this . chain . headers as any ) . height as number ) . toString ( 10 )
118
- const td = ( ( this . chain . headers as any ) . td as number ) . toString ( 10 )
119
- const hash = ( ( this . chain . blocks as any ) . latest as any ) . hash ( )
118
+ const number = this . chain . headers . height . toString ( 10 )
119
+ const td = this . chain . headers . td . toString ( 10 )
120
+ const hash = this . chain . blocks . latest ! . hash ( )
120
121
this . config . logger . info ( `Latest local header: number=${ number } td=${ td } hash=${ short ( hash ) } ` )
121
122
}
122
123
0 commit comments