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.

53 lines
1.5 KiB

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