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/api.go | |
parent | eac390f28955d66f9152102058e0d85d972bc033 (diff) | |
download | go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.gz go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.bz2 go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.lz go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.xz go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.zst go-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.zip |
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. |