Browse Source

rpc: make time human readable. closes #926

pull/927/head
Ethan Buchman 7 years ago
parent
commit
d0dc04001e
2 changed files with 11 additions and 6 deletions
  1. +9
    -5
      rpc/core/status.go
  2. +2
    -1
      rpc/core/types/responses.go

+ 9
- 5
rpc/core/status.go View File

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


+ 2
- 1
rpc/core/types/responses.go View File

@ -2,6 +2,7 @@ package core_types
import ( import (
"strings" "strings"
"time"
abci "github.com/tendermint/abci/types" abci "github.com/tendermint/abci/types"
crypto "github.com/tendermint/go-crypto" crypto "github.com/tendermint/go-crypto"
@ -52,7 +53,7 @@ type ResultStatus struct {
LatestBlockHash data.Bytes `json:"latest_block_hash"` LatestBlockHash data.Bytes `json:"latest_block_hash"`
LatestAppHash data.Bytes `json:"latest_app_hash"` LatestAppHash data.Bytes `json:"latest_app_hash"`
LatestBlockHeight int64 `json:"latest_block_height"` LatestBlockHeight int64 `json:"latest_block_height"`
LatestBlockTime int64 `json:"latest_block_time"` // nano
LatestBlockTime time.Time `json:"latest_block_time"` // nano
Syncing bool `json:"syncing"` Syncing bool `json:"syncing"`
} }


Loading…
Cancel
Save