aboutsummaryrefslogtreecommitdiffstats
path: root/eth/sync.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/sync.go')
-rw-r--r--eth/sync.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/eth/sync.go b/eth/sync.go
index b51fb7c10..c89f34596 100644
--- a/eth/sync.go
+++ b/eth/sync.go
@@ -40,9 +40,7 @@ func (pm *ProtocolManager) update() {
// Try to pull some blocks from the downloaded
if atomic.CompareAndSwapInt32(&blockProcPend, 0, 1) {
go func() {
- if err := pm.processBlocks(); err != nil {
- pm.downloader.Cancel()
- }
+ pm.processBlocks()
atomic.StoreInt32(&blockProcPend, 0)
}()
}
@@ -61,12 +59,8 @@ func (pm *ProtocolManager) processBlocks() error {
pm.wg.Add(1)
defer pm.wg.Done()
- // Take a batch of blocks, but abort if there's an invalid head or if the chain's empty
- blocks, err := pm.downloader.TakeBlocks()
- if err != nil {
- glog.V(logger.Warn).Infof("Block processing failed: %v", err)
- return err
- }
+ // Short circuit if no blocks are available for insertion
+ blocks := pm.downloader.TakeBlocks()
if len(blocks) == 0 {
return nil
}
@@ -77,6 +71,7 @@ func (pm *ProtocolManager) processBlocks() error {
_, err := pm.chainman.InsertChain(blocks[:max])
if err != nil {
glog.V(logger.Warn).Infof("Block insertion failed: %v", err)
+ pm.downloader.Cancel()
return err
}
blocks = blocks[max:]