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.

43 lines
1.2 KiB

  1. package core
  2. import (
  3. ctypes "github.com/tendermint/tendermint/rpc/core/types"
  4. )
  5. //-----------------------------------------------------------------------------
  6. func NetInfo() (*ctypes.ResultNetInfo, error) {
  7. listening := p2pSwitch.IsListening()
  8. listeners := []string{}
  9. for _, listener := range p2pSwitch.Listeners() {
  10. listeners = append(listeners, listener.String())
  11. }
  12. peers := []ctypes.Peer{}
  13. for _, peer := range p2pSwitch.Peers().List() {
  14. peers = append(peers, ctypes.Peer{
  15. NodeInfo: *peer.NodeInfo,
  16. IsOutbound: peer.IsOutbound(),
  17. ConnectionStatus: peer.Connection().Status(),
  18. })
  19. }
  20. return &ctypes.ResultNetInfo{
  21. Listening: listening,
  22. Listeners: listeners,
  23. Peers: peers,
  24. }, nil
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Dial given list of seeds
  28. func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
  29. // starts go routines to dial each seed after random delays
  30. p2pSwitch.DialSeeds(seeds)
  31. return &ctypes.ResultDialSeeds{}, nil
  32. }
  33. //-----------------------------------------------------------------------------
  34. func Genesis() (*ctypes.ResultGenesis, error) {
  35. return &ctypes.ResultGenesis{genDoc}, nil
  36. }