mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth/downloader: return error only if master peer
This commit is contained in:
parent
f0869777e7
commit
2b183c8355
2 changed files with 18 additions and 4 deletions
|
|
@ -559,6 +559,14 @@ func (d *Downloader) spawnSync(fetchers []func() error) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// isMaster returns an indicator whether the given peer id is master peer
|
||||
// used for syncing.
|
||||
func (d *Downloader) isMaster(id string) bool {
|
||||
d.cancelLock.Lock()
|
||||
defer d.cancelLock.Unlock()
|
||||
return d.cancelPeer == id
|
||||
}
|
||||
|
||||
// cancel aborts all of the operations and resets the queue. However, cancel does
|
||||
// not wait for the running download goroutines to finish. This method should be
|
||||
// used when cancelling the downloads from inside the downloader.
|
||||
|
|
@ -1284,9 +1292,12 @@ func (d *Downloader) fetchParts(deliveryCh chan dataPack, deliver func(dataPack)
|
|||
peer.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", pid)
|
||||
} else {
|
||||
// In dropPeer function, a callback will be called which aborts
|
||||
// the sync immediately. Here return the timeout error explicitly.
|
||||
// the sync immediately if the unregisted peer is master peer.
|
||||
// If the peer is master one, return concrete error here.
|
||||
d.dropPeer(pid)
|
||||
return errTimeout
|
||||
if d.isMaster(pid) {
|
||||
return errTimeout
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,9 +317,12 @@ func (s *stateSync) loop() (err error) {
|
|||
req.peer.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", req.peer.id)
|
||||
} else {
|
||||
// In dropPeer function, a callback will be called which aborts
|
||||
// the sync immediately. Here return the timeout error explicitly.
|
||||
// the sync immediately if the unregisted peer is master peer.
|
||||
// If the peer is master one, return concrete error here.
|
||||
s.d.dropPeer(req.peer.id)
|
||||
return errTimeout
|
||||
if s.d.isMaster(req.peer.id) {
|
||||
return errTimeout
|
||||
}
|
||||
}
|
||||
}
|
||||
// Process all the received blobs and check for stale delivery
|
||||
|
|
|
|||
Loading…
Reference in a new issue