You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
828 B

  1. package core
  2. import (
  3. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  4. "github.com/tendermint/tendermint/types"
  5. )
  6. func Status() (*ctypes.ResultStatus, error) {
  7. latestHeight := blockStore.Height()
  8. var (
  9. latestBlockMeta *types.BlockMeta
  10. latestBlockHash []byte
  11. latestAppHash []byte
  12. latestBlockTime int64
  13. )
  14. if latestHeight != 0 {
  15. latestBlockMeta = blockStore.LoadBlockMeta(latestHeight)
  16. latestBlockHash = latestBlockMeta.BlockID.Hash
  17. latestAppHash = latestBlockMeta.Header.AppHash
  18. latestBlockTime = latestBlockMeta.Header.Time.UnixNano()
  19. }
  20. return &ctypes.ResultStatus{
  21. NodeInfo: p2pSwitch.NodeInfo(),
  22. PubKey: pubKey,
  23. LatestBlockHash: latestBlockHash,
  24. LatestAppHash: latestAppHash,
  25. LatestBlockHeight: latestHeight,
  26. LatestBlockTime: latestBlockTime}, nil
  27. }