diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 813d8f6b7..eca0a6251 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -267,6 +267,11 @@ func (bcR *BlockchainReactor) SetEventSwitch(evsw types.EventSwitch) { bcR.evsw = evsw } +// FastSync returns whether the blockchain reactor is currently fast syncing +func (bcR *BlockchainReactor) FastSync() bool { + return bcR.fastSync +} + //----------------------------------------------------------------------------- // Messages diff --git a/node/node.go b/node/node.go index 672e384b9..f11c01398 100644 --- a/node/node.go +++ b/node/node.go @@ -315,6 +315,7 @@ func (n *Node) ConfigureRPC() { rpccore.SetAddrBook(n.addrBook) rpccore.SetProxyAppQuery(n.proxyApp.Query()) rpccore.SetTxIndexer(n.txIndexer) + rpccore.SetBlockchainReactor(n.bcReactor) rpccore.SetLogger(n.Logger.With("module", "rpc")) } diff --git a/rpc/core/pipe.go b/rpc/core/pipe.go index a18de2ad8..e581de8b9 100644 --- a/rpc/core/pipe.go +++ b/rpc/core/pipe.go @@ -2,6 +2,7 @@ package core import ( crypto "github.com/tendermint/go-crypto" + "github.com/tendermint/tendermint/blockchain" "github.com/tendermint/tendermint/consensus" p2p "github.com/tendermint/tendermint/p2p" "github.com/tendermint/tendermint/proxy" @@ -45,6 +46,7 @@ var ( genDoc *types.GenesisDoc // cache the genesis structure addrBook *p2p.AddrBook txIndexer txindex.TxIndexer + bcReactor *blockchain.BlockchainReactor logger log.Logger ) @@ -89,6 +91,10 @@ func SetTxIndexer(indexer txindex.TxIndexer) { txIndexer = indexer } +func SetBlockchainReactor(bc *blockchain.BlockchainReactor) { + bcReactor = bc +} + func SetLogger(l log.Logger) { logger = l } diff --git a/rpc/core/status.go b/rpc/core/status.go index 7493aeb0a..ca83031c9 100644 --- a/rpc/core/status.go +++ b/rpc/core/status.go @@ -27,5 +27,6 @@ func Status() (*ctypes.ResultStatus, error) { LatestBlockHash: latestBlockHash, LatestAppHash: latestAppHash, LatestBlockHeight: latestHeight, - LatestBlockTime: latestBlockTime}, nil + LatestBlockTime: latestBlockTime, + Syncing: bcReactor.FastSync()}, nil } diff --git a/rpc/core/types/responses.go b/rpc/core/types/responses.go index b9c22a8b0..6b66f1168 100644 --- a/rpc/core/types/responses.go +++ b/rpc/core/types/responses.go @@ -38,6 +38,7 @@ type ResultStatus struct { LatestAppHash data.Bytes `json:"latest_app_hash"` LatestBlockHeight int `json:"latest_block_height"` LatestBlockTime int64 `json:"latest_block_time"` // nano + Syncing bool `json:"syncing"` } func (s *ResultStatus) TxIndexEnabled() bool {