diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 02:20:59 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 02:20:59 +0800 |
commit | 1cc4bd76dbec6da4355a37cf68de808fcf0c95a3 (patch) | |
tree | 55f4c409ba14206bb94beda7f1fd49f880bff008 /eth/downloader/downloader.go | |
parent | be79b4aacb57d15ae73c376099ee1688d548b6b3 (diff) | |
parent | 59cd60b266ebec20e441b8508671a579630b9870 (diff) | |
download | go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.gz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.bz2 go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.lz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.xz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.zst go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.zip |
Merge pull request #2193 from karalabe/sync-state-reports
eth, eth/downloader, jsre: surface state sync progress through the API
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r-- | eth/downloader/downloader.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 698b99f8b..6dad6a2cd 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -196,7 +196,15 @@ func New(stateDb ethdb.Database, mux *event.TypeMux, hasHeader headerCheckFn, ha // Progress retrieves the synchronisation boundaries, specifically the origin // block where synchronisation started at (may have failed/suspended); the block // or header sync is currently at; and the latest known block which the sync targets. -func (d *Downloader) Progress() (uint64, uint64, uint64) { +// +// In addition, during the state download phase of fast synchonisation the number +// of processed and the total number of known states are also returned. Otherwise +// these are zero. +func (d *Downloader) Progress() (uint64, uint64, uint64, uint64, uint64) { + // Fetch the pending state count outside of the lock to prevent unforeseen deadlocks + pendingStates := uint64(d.queue.PendingNodeData()) + + // Lock the current stats and return the progress d.syncStatsLock.RLock() defer d.syncStatsLock.RUnlock() @@ -209,7 +217,7 @@ func (d *Downloader) Progress() (uint64, uint64, uint64) { case LightSync: current = d.headHeader().Number.Uint64() } - return d.syncStatsChainOrigin, current, d.syncStatsChainHeight + return d.syncStatsChainOrigin, current, d.syncStatsChainHeight, d.syncStatsStateDone, d.syncStatsStateDone + pendingStates } // Synchronising returns whether the downloader is currently retrieving blocks. @@ -296,7 +304,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode default: } } - // Reset and ephemeral sync statistics + // Reset any ephemeral sync statistics d.syncStatsLock.Lock() d.syncStatsStateTotal = 0 d.syncStatsStateDone = 0 |