2015-12-21 15:13:42 -08:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2017-04-21 15:13:25 -07:00
|
|
|
data "github.com/tendermint/go-wire/data"
|
2017-04-26 16:57:33 -07:00
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
2015-12-21 15:13:42 -08:00
|
|
|
"github.com/tendermint/tendermint/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Status() (*ctypes.ResultStatus, error) {
|
|
|
|
latestHeight := blockStore.Height()
|
|
|
|
var (
|
|
|
|
latestBlockMeta *types.BlockMeta
|
2017-03-22 12:13:18 -07:00
|
|
|
latestBlockHash data.Bytes
|
|
|
|
latestAppHash data.Bytes
|
2015-12-21 15:13:42 -08:00
|
|
|
latestBlockTime int64
|
|
|
|
)
|
|
|
|
if latestHeight != 0 {
|
|
|
|
latestBlockMeta = blockStore.LoadBlockMeta(latestHeight)
|
2017-02-14 12:33:14 -08:00
|
|
|
latestBlockHash = latestBlockMeta.BlockID.Hash
|
2015-12-21 15:13:42 -08:00
|
|
|
latestAppHash = latestBlockMeta.Header.AppHash
|
|
|
|
latestBlockTime = latestBlockMeta.Header.Time.UnixNano()
|
|
|
|
}
|
|
|
|
|
|
|
|
return &ctypes.ResultStatus{
|
|
|
|
NodeInfo: p2pSwitch.NodeInfo(),
|
2016-10-14 18:36:42 -07:00
|
|
|
PubKey: pubKey,
|
2015-12-21 15:13:42 -08:00
|
|
|
LatestBlockHash: latestBlockHash,
|
|
|
|
LatestAppHash: latestAppHash,
|
|
|
|
LatestBlockHeight: latestHeight,
|
|
|
|
LatestBlockTime: latestBlockTime}, nil
|
|
|
|
}
|