diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-09-06 18:59:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 18:59:41 +0800 |
commit | 6fb8ae2bd6eb2b28f9b44799a8299183d634be80 (patch) | |
tree | 8ff6bb9a21870f6b26d2887ad82949a923d0d4df /eth/downloader/api.go | |
parent | eac390f28955d66f9152102058e0d85d972bc033 (diff) | |
parent | 2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809 (diff) | |
download | dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar.gz dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar.bz2 dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar.lz dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar.xz dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.tar.zst dexon-6fb8ae2bd6eb2b28f9b44799a8299183d634be80.zip |
Merge pull request #2979 from karalabe/ethclient-sync-api
ethereum, ethclient: add SyncProgress API endpoint
Diffstat (limited to 'eth/downloader/api.go')
-rw-r--r-- | eth/downloader/api.go | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/eth/downloader/api.go b/eth/downloader/api.go index c36dfb7e0..e41376810 100644 --- a/eth/downloader/api.go +++ b/eth/downloader/api.go @@ -19,6 +19,7 @@ package downloader import ( "sync" + ethereum "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rpc" "golang.org/x/net/context" @@ -73,9 +74,10 @@ func (api *PublicDownloaderAPI) eventLoop() { var notification interface{} switch event.Data.(type) { case StartEvent: - result := &SyncingResult{Syncing: true} - result.Status.Origin, result.Status.Current, result.Status.Height, result.Status.Pulled, result.Status.Known = api.d.Progress() - notification = result + notification = &SyncingResult{ + Syncing: true, + Status: api.d.Progress(), + } case DoneEvent, FailedEvent: notification = false } @@ -117,19 +119,10 @@ func (api *PublicDownloaderAPI) Syncing(ctx context.Context) (*rpc.Subscription, return rpcSub, nil } -// Progress gives progress indications when the node is synchronising with the Ethereum network. -type Progress struct { - Origin uint64 `json:"startingBlock"` - Current uint64 `json:"currentBlock"` - Height uint64 `json:"highestBlock"` - Pulled uint64 `json:"pulledStates"` - Known uint64 `json:"knownStates"` -} - // SyncingResult provides information about the current synchronisation status for this node. type SyncingResult struct { - Syncing bool `json:"syncing"` - Status Progress `json:"status"` + Syncing bool `json:"syncing"` + Status ethereum.SyncProgress `json:"status"` } // uninstallSyncSubscriptionRequest uninstalles a syncing subscription in the API event loop. |