mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
light fetcher shutdown
This commit is contained in:
parent
a09e88d4bf
commit
78a077372c
2 changed files with 6 additions and 3 deletions
|
|
@ -115,6 +115,8 @@ func (f *lightFetcher) fetchBestFromPool() *peer {
|
|||
func (f *lightFetcher) syncLoop() {
|
||||
for {
|
||||
select {
|
||||
case <-f.pm.quitSync:
|
||||
return
|
||||
case <-f.syncPoolNotify:
|
||||
chn := f.pm.getSyncLock(false)
|
||||
if chn != nil {
|
||||
|
|
@ -131,13 +133,14 @@ func (f *lightFetcher) syncLoop() {
|
|||
}()
|
||||
}
|
||||
}
|
||||
case <-f.pm.quitSync:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (f *lightFetcher) syncWithPeer(p *peer) bool {
|
||||
f.pm.wg.Add(1)
|
||||
defer f.pm.wg.Done()
|
||||
|
||||
headNum := f.chain.CurrentHeader().Number.Uint64()
|
||||
peerHead := p.headBlockInfo()
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func (pm *ProtocolManager) syncer() {
|
|||
func (pm *ProtocolManager) needToSync(peerHead blockInfo) bool {
|
||||
head := pm.blockchain.CurrentHeader()
|
||||
currentTd := core.GetTd(pm.chainDb, head.Hash(), head.Number.Uint64())
|
||||
return peerHead.Td.Cmp(currentTd) > 0
|
||||
return currentTd != nil && peerHead.Td.Cmp(currentTd) > 0
|
||||
}
|
||||
|
||||
// synchronise tries to sync up our local block chain with a remote peer.
|
||||
|
|
|
|||
Loading…
Reference in a new issue