mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
downloader: only attempt common ancestor negotiation if > 0 local head
Eliminates a redundant negotiation if we can already deduce that our only common block is genesis. Signed-off-by: meows <b5c6@protonmail.com>
This commit is contained in:
parent
12f6c7642c
commit
db63f1ee42
1 changed files with 11 additions and 3 deletions
|
|
@ -441,10 +441,18 @@ func (d *Downloader) syncWithPeer(p *peerConnection, hash common.Hash, td *big.I
|
||||||
}
|
}
|
||||||
height := latest.Number.Uint64()
|
height := latest.Number.Uint64()
|
||||||
|
|
||||||
origin, err := d.findAncestor(p, latest)
|
var origin = uint64(0)
|
||||||
if err != nil {
|
|
||||||
return err
|
if d.blockchain != nil &&
|
||||||
|
d.blockchain.CurrentHeader() != nil &&
|
||||||
|
d.blockchain.CurrentHeader().Number != nil &&
|
||||||
|
d.blockchain.CurrentHeader().Number.Uint64() > 0 {
|
||||||
|
origin, err = d.findAncestor(p, latest)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.syncStatsLock.Lock()
|
d.syncStatsLock.Lock()
|
||||||
if d.syncStatsChainHeight <= origin || d.syncStatsChainOrigin > origin {
|
if d.syncStatsChainHeight <= origin || d.syncStatsChainOrigin > origin {
|
||||||
d.syncStatsChainOrigin = origin
|
d.syncStatsChainOrigin = origin
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue