core, eth, les, light: get rid of redundant methods
This commit is contained in:
@ -164,8 +164,8 @@ type LightChain interface {
|
||||
// CurrentHeader retrieves the head header from the local chain.
|
||||
CurrentHeader() *types.Header
|
||||
|
||||
// GetTdByHash returns the total difficulty of a local block.
|
||||
GetTdByHash(common.Hash) *big.Int
|
||||
// GetTd returns the total difficulty of a local block.
|
||||
GetTd(common.Hash, uint64) *big.Int
|
||||
|
||||
// InsertHeaderChain inserts a batch of headers into the local chain.
|
||||
InsertHeaderChain([]*types.Header, int) (int, error)
|
||||
@ -1218,7 +1218,8 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int) error {
|
||||
// L: Request new headers up from 11 (R's TD was higher, it must have something)
|
||||
// R: Nothing to give
|
||||
if d.mode != LightSync {
|
||||
if !gotHeaders && td.Cmp(d.blockchain.GetTdByHash(d.blockchain.CurrentBlock().Hash())) > 0 {
|
||||
head := d.blockchain.CurrentBlock()
|
||||
if !gotHeaders && td.Cmp(d.blockchain.GetTd(head.Hash(), head.NumberU64())) > 0 {
|
||||
return errStallingPeer
|
||||
}
|
||||
}
|
||||
@ -1230,7 +1231,8 @@ func (d *Downloader) processHeaders(origin uint64, td *big.Int) error {
|
||||
// queued for processing when the header download completes. However, as long as the
|
||||
// peer gave us something useful, we're already happy/progressed (above check).
|
||||
if d.mode == FastSync || d.mode == LightSync {
|
||||
if td.Cmp(d.lightchain.GetTdByHash(d.lightchain.CurrentHeader().Hash())) > 0 {
|
||||
head := d.lightchain.CurrentHeader()
|
||||
if td.Cmp(d.lightchain.GetTd(head.Hash(), head.Number.Uint64())) > 0 {
|
||||
return errStallingPeer
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +299,8 @@ func (dl *downloadTester) FastSyncCommitHead(hash common.Hash) error {
|
||||
return fmt.Errorf("non existent block: %x", hash[:4])
|
||||
}
|
||||
|
||||
// GetTdByHash retrieves the block's total difficulty from the canonical chain.
|
||||
func (dl *downloadTester) GetTdByHash(hash common.Hash) *big.Int {
|
||||
// GetTd retrieves the block's total difficulty from the canonical chain.
|
||||
func (dl *downloadTester) GetTd(hash common.Hash, number uint64) *big.Int {
|
||||
dl.lock.RLock()
|
||||
defer dl.lock.RUnlock()
|
||||
|
||||
|
Reference in New Issue
Block a user