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 11:13:45 -07:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-12-08 21:26:07 -08:00
|
|
|
// Dial given list of seeds
|
2016-01-20 10:12:42 -08:00
|
|
|
func DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
|
|
|
|
// starts go routines to dial each seed after random delays
|
|
|
|
p2pSwitch.DialSeeds(seeds)
|
|
|
|
return &ctypes.ResultDialSeeds{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-08-10 20:38:45 -07:00
|
|
|
func Genesis() (*ctypes.ResultGenesis, error) {
|
|
|
|
return &ctypes.ResultGenesis{genDoc}, nil
|
2015-05-29 11:13:45 -07:00
|
|
|
}
|