mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
eth/downloader: fix #2841 spikes by block fetches
Ignore a reportedly higher total difficulty when a peer's best block is already present in local chain. Makes robust against inaccurately reported height or total difficulty.
This commit is contained in:
parent
f273c64a94
commit
82199692b0
1 changed files with 8 additions and 0 deletions
|
|
@ -412,6 +412,14 @@ func (d *Downloader) syncWithPeer(p *peer, hash common.Hash, td *big.Int) (err e
|
||||||
)
|
)
|
||||||
|
|
||||||
case p.version >= 62:
|
case p.version >= 62:
|
||||||
|
// essentially double check the peer-reported height. If its
|
||||||
|
// block at that height turns out to already be in our chain,
|
||||||
|
// stop search and ignore the alleged higher total difficulty
|
||||||
|
if d.hasBlockAndState(p.head) {
|
||||||
|
glog.Infof("%v: advertised a head already in our chain. Ignoring reported higher total difficulty", p)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Look up the sync boundaries: the common ancestor and the target block
|
// Look up the sync boundaries: the common ancestor and the target block
|
||||||
latest, err := d.fetchHeight(p)
|
latest, err := d.fetchHeight(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue