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