eth/downloader: fix leftover state between syncs

This commit is contained in:
Péter Szilágyi 2015-05-08 17:21:11 +03:00
parent bd5720f480
commit edad47bf0e
1 changed files with 4 additions and 1 deletions

View File

@ -130,9 +130,12 @@ func (d *Downloader) Synchronise(id string, hash common.Hash) error {
defer atomic.StoreInt32(&d.synchronising, 0)
// Abort if the queue still contains some leftover data
if _, cached := d.queue.Size(); cached > 0 {
if _, cached := d.queue.Size(); cached > 0 && d.queue.GetHeadBlock() != nil {
return errPendingQueue
}
// Reset the queue to clean any internal leftover state
d.queue.Reset()
// Retrieve the origin peer and initiate the downloading process
p := d.peers[id]
if p == nil {