2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2015-04-07 11:44:25 -07: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) {
|
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-03-03 01:27:41 -05:00
|
|
|
return &ctypes.ResultDialSeeds{}, err
|
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
|
|
|
}
|