diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-09-16 17:31:58 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-09-16 17:31:58 +0800 |
commit | 1cc2f080417ba77ecb66a058727e00f6644c5e7b (patch) | |
tree | cfefd407942890c51a04d3038bff4129bd1ca2ac /rpc/api/eth.go | |
parent | e9a80518c72e0d5b2da7246a865f4dc4baab2cf9 (diff) | |
parent | d4d3fc6a702d87bab7e04dcd5085a83205107c1c (diff) | |
download | dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar.gz dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar.bz2 dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar.lz dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar.xz dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.tar.zst dexon-1cc2f080417ba77ecb66a058727e00f6644c5e7b.zip |
Merge pull request #1784 from karalabe/standard-sync-stats
eth, rpc: standardize the chain sync progress counters
Diffstat (limited to 'rpc/api/eth.go')
-rw-r--r-- | rpc/api/eth.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/rpc/api/eth.go b/rpc/api/eth.go index a93e41157..30366a951 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": newHexNum(big.NewInt(int64(origin)).Bytes()), + "currentBlock": newHexNum(big.NewInt(int64(current)).Bytes()), + "highestBlock": newHexNum(big.NewInt(int64(height)).Bytes()), + }, nil + } + return false, nil +} + func (self *ethApi) GasPrice(req *shared.Request) (interface{}, error) { return newHexNum(self.xeth.DefaultGasPrice().Bytes()), nil } |