diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 02:20:59 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-02-11 02:20:59 +0800 |
commit | 1cc4bd76dbec6da4355a37cf68de808fcf0c95a3 (patch) | |
tree | 55f4c409ba14206bb94beda7f1fd49f880bff008 /eth/api.go | |
parent | be79b4aacb57d15ae73c376099ee1688d548b6b3 (diff) | |
parent | 59cd60b266ebec20e441b8508671a579630b9870 (diff) | |
download | go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.gz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.bz2 go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.lz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.xz go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.tar.zst go-tangerine-1cc4bd76dbec6da4355a37cf68de808fcf0c95a3.zip |
Merge pull request #2193 from karalabe/sync-state-reports
eth, eth/downloader, jsre: surface state sync progress through the API
Diffstat (limited to 'eth/api.go')
-rw-r--r-- | eth/api.go | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/eth/api.go b/eth/api.go index 09ae0c468..3c01e2c11 100644 --- a/eth/api.go +++ b/eth/api.go @@ -152,21 +152,27 @@ func (s *PublicEthereumAPI) Hashrate() *rpc.HexNumber { } // Syncing returns false in case the node is currently not synching with the network. It can be up to date or has not -// yet received the latest block headers from its pears. In case it is synchronizing an object with 3 properties is -// returned: +// yet received the latest block headers from its pears. In case it is synchronizing: // - startingBlock: block number this node started to synchronise from -// - currentBlock: block number this node is currently importing -// - highestBlock: block number of the highest block header this node has received from peers +// - currentBlock: block number this node is currently importing +// - highestBlock: block number of the highest block header this node has received from peers +// - pulledStates: number of state entries processed until now +// - knownStates: number of known state entries that still need to be pulled func (s *PublicEthereumAPI) Syncing() (interface{}, error) { - origin, current, height := s.e.Downloader().Progress() - if current < height { - return map[string]interface{}{ - "startingBlock": rpc.NewHexNumber(origin), - "currentBlock": rpc.NewHexNumber(current), - "highestBlock": rpc.NewHexNumber(height), - }, nil - } - return false, nil + origin, current, height, pulled, known := s.e.Downloader().Progress() + + // Return not syncing if the synchronisation already completed + if current >= height { + return false, nil + } + // Otherwise gather the block sync stats + return map[string]interface{}{ + "startingBlock": rpc.NewHexNumber(origin), + "currentBlock": rpc.NewHexNumber(current), + "highestBlock": rpc.NewHexNumber(height), + "pulledStates": rpc.NewHexNumber(pulled), + "knownStates": rpc.NewHexNumber(known), + }, nil } // PublicMinerAPI provides an API to control the miner. |