diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-09-06 17:39:14 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-09-06 18:41:43 +0800 |
commit | 2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809 (patch) | |
tree | 8ff6bb9a21870f6b26d2887ad82949a923d0d4df /eth/downloader/downloader.go | |
parent | eac390f28955d66f9152102058e0d85d972bc033 (diff) | |
download | dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.gz dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.bz2 dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.lz dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.xz dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.zst dexon-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.zip |
ethereum, ethclient: add SyncProgress API endpoint
Diffstat (limited to 'eth/downloader/downloader.go')
-rw-r--r-- | eth/downloader/downloader.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index c8f710450..fb63757aa 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -28,6 +28,7 @@ import ( "sync/atomic" "time" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethdb" @@ -211,7 +212,7 @@ func New(stateDb ethdb.Database, mux *event.TypeMux, hasHeader headerCheckFn, ha // In addition, during the state download phase of fast synchronisation 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) { +func (d *Downloader) Progress() ethereum.SyncProgress { // Fetch the pending state count outside of the lock to prevent unforeseen deadlocks pendingStates := uint64(d.queue.PendingNodeData()) @@ -228,7 +229,13 @@ func (d *Downloader) Progress() (uint64, uint64, uint64, uint64, uint64) { case LightSync: current = d.headHeader().Number.Uint64() } - return d.syncStatsChainOrigin, current, d.syncStatsChainHeight, d.syncStatsStateDone, d.syncStatsStateDone + pendingStates + return ethereum.SyncProgress{ + StartingBlock: d.syncStatsChainOrigin, + CurrentBlock: current, + HighestBlock: d.syncStatsChainHeight, + PulledStates: d.syncStatsStateDone, + KnownStates: d.syncStatsStateDone + pendingStates, + } } // Synchronising returns whether the downloader is currently retrieving blocks. |