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.

58 lines
1.6 KiB

  1. package core
  2. import (
  3. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  4. "github.com/tendermint/tendermint/types"
  5. )
  6. //-----------------------------------------------------------------------------
  7. // TODO Move to status.go or node.go
  8. func Status() (*ctypes.ResultStatus, error) {
  9. latestHeight := blockStore.Height()
  10. var (
  11. latestBlockMeta *types.BlockMeta
  12. latestBlockHash []byte
  13. latestBlockTime int64
  14. )
  15. if latestHeight != 0 {
  16. latestBlockMeta = blockStore.LoadBlockMeta(latestHeight)
  17. latestBlockHash = latestBlockMeta.Hash
  18. latestBlockTime = latestBlockMeta.Header.Time.UnixNano()
  19. }
  20. return &ctypes.ResultStatus{
  21. NodeInfo: p2pSwitch.NodeInfo(),
  22. PubKey: privValidator.PubKey,
  23. LatestBlockHash: latestBlockHash,
  24. LatestBlockHeight: latestHeight,
  25. LatestBlockTime: latestBlockTime}, nil
  26. }
  27. //-----------------------------------------------------------------------------
  28. func NetInfo() (*ctypes.ResultNetInfo, error) {
  29. listening := p2pSwitch.IsListening()
  30. listeners := []string{}
  31. for _, listener := range p2pSwitch.Listeners() {
  32. listeners = append(listeners, listener.String())
  33. }
  34. peers := []ctypes.Peer{}
  35. for _, peer := range p2pSwitch.Peers().List() {
  36. peers = append(peers, ctypes.Peer{
  37. NodeInfo: *peer.NodeInfo,
  38. IsOutbound: peer.IsOutbound(),
  39. })
  40. }
  41. return &ctypes.ResultNetInfo{
  42. Listening: listening,
  43. Listeners: listeners,
  44. Peers: peers,
  45. }, nil
  46. }
  47. //-----------------------------------------------------------------------------
  48. func Genesis() (*ctypes.ResultGenesis, error) {
  49. return &ctypes.ResultGenesis{genDoc}, nil
  50. }