rpc: make time human readable. closes #926

This commit is contained in:
Ethan Buchman
2017-12-06 01:25:11 -05:00
parent e101aa9fc8
commit d0dc04001e
2 changed files with 11 additions and 6 deletions

View File

@@ -1,6 +1,8 @@
package core
import (
"time"
data "github.com/tendermint/go-wire/data"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/tendermint/tendermint/types"
@@ -56,18 +58,20 @@ import (
func Status() (*ctypes.ResultStatus, error) {
latestHeight := blockStore.Height()
var (
latestBlockMeta *types.BlockMeta
latestBlockHash data.Bytes
latestAppHash data.Bytes
latestBlockTime int64
latestBlockMeta *types.BlockMeta
latestBlockHash data.Bytes
latestAppHash data.Bytes
latestBlockTimeNano int64
)
if latestHeight != 0 {
latestBlockMeta = blockStore.LoadBlockMeta(latestHeight)
latestBlockHash = latestBlockMeta.BlockID.Hash
latestAppHash = latestBlockMeta.Header.AppHash
latestBlockTime = latestBlockMeta.Header.Time.UnixNano()
latestBlockTimeNano = latestBlockMeta.Header.Time.UnixNano()
}
latestBlockTime := time.Unix(0, latestBlockTimeNano)
return &ctypes.ResultStatus{
NodeInfo: p2pSwitch.NodeInfo(),
PubKey: pubKey,