aboutsummaryrefslogtreecommitdiffstats
path: root/eth/downloader/api.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-09-06 17:39:14 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-09-06 18:41:43 +0800
commit2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809 (patch)
tree8ff6bb9a21870f6b26d2887ad82949a923d0d4df /eth/downloader/api.go
parenteac390f28955d66f9152102058e0d85d972bc033 (diff)
downloadgo-tangerine-2924fdfcf7ab67a66a4ed3fb95cb9140be0cc809.tar.gz
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.go21
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.