2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2017-04-12 19:12:22 -04:00
|
|
|
"fmt"
|
|
|
|
|
2017-04-26 19:57:33 -04:00
|
|
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
2015-03-26 21:30:42 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
func NetInfo() (*ctypes.ResultNetInfo, error) {
|
2015-03-26 21:30:42 -07:00
|
|
|
listening := p2pSwitch.IsListening()
|
2015-04-03 16:15:52 -07:00
|
|
|
listeners := []string{}
|
|
|
|
for _, listener := range p2pSwitch.Listeners() {
|
|
|
|
listeners = append(listeners, listener.String())
|
|
|
|
}
|
2015-04-17 18:22:44 -07:00
|
|
|
peers := []ctypes.Peer{}
|
2015-04-03 16:15:52 -07:00
|
|
|
for _, peer := range p2pSwitch.Peers().List() {
|
2015-04-17 18:22:44 -07:00
|
|
|
peers = append(peers, ctypes.Peer{
|
2016-01-03 06:21:56 -08:00
|
|
|
NodeInfo: *peer.NodeInfo,
|
|
|
|
IsOutbound: peer.IsOutbound(),
|
|
|
|
ConnectionStatus: peer.Connection().Status(),
|
2015-04-17 18:22:44 -07:00
|
|
|
})
|
2015-04-03 16:15:52 -07:00
|
|
|
}
|
2015-08-10 20:38:45 -07:00
|
|
|
return &ctypes.ResultNetInfo{
|
2015-04-03 16:15:52 -07:00
|
|
|
Listening: listening,
|
|
|
|
Listeners: listeners,
|
|
|
|
Peers: peers,
|
|
|
|
}, nil
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
2015-05-29 14:13:45 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-12-09 00:26:07 -05:00
|
|
|
// Dial given list of seeds
|
2016-12-12 14:12:13 -05:00
|
|
|
func UnsafeDialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
2017-04-12 19:12:22 -04:00
|
|
|
|
|
|
|
if len(seeds) == 0 {
|
|
|
|
return &ctypes.ResultDialSeeds{}, fmt.Errorf("No seeds provided")
|
|
|
|
}
|
2016-01-20 13:12:42 -05:00
|
|
|
// starts go routines to dial each seed after random delays
|
2017-03-05 23:13:34 -05:00
|
|
|
log.Info("DialSeeds", "addrBook", addrBook, "seeds", seeds)
|
|
|
|
err := p2pSwitch.DialSeeds(addrBook, seeds)
|
2017-04-12 19:12:22 -04:00
|
|
|
if err != nil {
|
|
|
|
return &ctypes.ResultDialSeeds{}, err
|
|
|
|
}
|
|
|
|
return &ctypes.ResultDialSeeds{"Dialing seeds in progress. See /net_info for details"}, nil
|
2016-01-20 13:12:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
func Genesis() (*ctypes.ResultGenesis, error) {
|
|
|
|
return &ctypes.ResultGenesis{genDoc}, nil
|
2015-05-29 14:13:45 -04:00
|
|
|
}
|