diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-01-06 21:42:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-06 21:42:03 +0800 |
commit | 8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184 (patch) | |
tree | 92a336065bddcd620798e8f552432e3ed62ee14a /eth/downloader/queue.go | |
parent | e0ee0cc66a4416edd47232649f4d4bca4a5e3c07 (diff) | |
parent | d3b751e4d94f95f6cc89544852f2d5811e075665 (diff) | |
download | go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.gz go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.bz2 go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.lz go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.xz go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.tar.zst go-tangerine-8f9daaa3ba71c3b6bdcc24adfdc987e6f3a2e184.zip |
Merge pull request #3518 from fjl/ethclient-dependency-cleanup
core/types: dependency cleanup
Diffstat (limited to 'eth/downloader/queue.go')
-rw-r--r-- | eth/downloader/queue.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index b7ad92099..060eaf970 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -1123,15 +1123,20 @@ func (q *queue) deliverNodeData(results []trie.SyncResult, callback func(int, bo callback(i, progressed, errNoFetchesPending) return } - if prog, _, err := q.stateScheduler.Process([]trie.SyncResult{result}); err != nil { - // Processing a state result failed, bail out + + batch := q.stateDatabase.NewBatch() + prog, _, err := q.stateScheduler.Process([]trie.SyncResult{result}, batch) + if err != nil { + q.stateSchedLock.Unlock() + callback(i, progressed, err) + } + if err = batch.Write(); err != nil { q.stateSchedLock.Unlock() callback(i, progressed, err) - return - } else if prog { - progressed = true } + // Item processing succeeded, release the lock (temporarily) + progressed = progressed || prog q.stateSchedLock.Unlock() } callback(len(results), progressed, nil) |