eth: don't block sync goroutines that short circuit

This commit is contained in:
Péter Szilágyi
2015-10-28 16:41:01 +02:00
parent 6b5a42a15c
commit 2019ed71b4
2 changed files with 9 additions and 4 deletions

View File

@ -170,13 +170,16 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
if pm.fastSync {
mode = downloader.FastSync
}
pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), mode)
if err := pm.downloader.Synchronise(peer.id, peer.Head(), peer.Td(), mode); err != nil {
return
}
// If fast sync was enabled, and we synced up, disable it
if pm.fastSync {
// Wait until all pending imports finish processing
for pm.downloader.Synchronising() {
time.Sleep(100 * time.Millisecond)
}
// Disable fast sync if we indeed have something in our chain
if pm.blockchain.CurrentBlock().NumberU64() > 0 {
glog.V(logger.Info).Infof("fast sync complete, auto disabling")
pm.fastSync = false