aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/eth.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-09-10 00:02:54 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-09-15 19:45:53 +0800
commit0a7d059b6a4365c671386855289bfdc3178e2d60 (patch)
tree41a01bf186506d820f652fa7b5c2bebb081ea999 /rpc/api/eth.go
parent071e2cd08e5492b5f4bae4f7dda03c5d47a0cd1d (diff)
downloaddexon-0a7d059b6a4365c671386855289bfdc3178e2d60.tar.gz
dexon-0a7d059b6a4365c671386855289bfdc3178e2d60.tar.zst
dexon-0a7d059b6a4365c671386855289bfdc3178e2d60.zip
eth, rpc: standardize the chain sync progress counters
Diffstat (limited to 'rpc/api/eth.go')
-rw-r--r--rpc/api/eth.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/rpc/api/eth.go b/rpc/api/eth.go
index a93e41157..9680536c6 100644
--- a/rpc/api/eth.go
+++ b/rpc/api/eth.go
@@ -55,6 +55,7 @@ var (
"eth_protocolVersion": (*ethApi).ProtocolVersion,
"eth_coinbase": (*ethApi).Coinbase,
"eth_mining": (*ethApi).IsMining,
+ "eth_syncing": (*ethApi).IsSyncing,
"eth_gasPrice": (*ethApi).GasPrice,
"eth_getStorage": (*ethApi).GetStorage,
"eth_storageAt": (*ethApi).GetStorage,
@@ -166,6 +167,20 @@ func (self *ethApi) IsMining(req *shared.Request) (interface{}, error) {
return self.xeth.IsMining(), nil
}
+func (self *ethApi) IsSyncing(req *shared.Request) (interface{}, error) {
+ current := self.ethereum.ChainManager().CurrentBlock().NumberU64()
+ origin, height := self.ethereum.Downloader().Boundaries()
+
+ if current < height {
+ return map[string]interface{}{
+ "startingBlock": origin,
+ "currentBlock": current,
+ "highestBlock": height,
+ }, nil
+ }
+ return false, nil
+}
+
func (self *ethApi) GasPrice(req *shared.Request) (interface{}, error) {
return newHexNum(self.xeth.DefaultGasPrice().Bytes()), nil
}