1
0
mirror of https://github.com/fluencelabs/tendermint synced 2025-06-27 03:31:42 +00:00
Files
DOCKER
benchmarks
blockchain
cmd
config
consensus
mempool
node
proxy
rpc
core
types
blocks.go
consensus.go
dev.go
events.go
log.go
mempool.go
net.go
pipe.go
routes.go
status.go
tmsp.go
version.go
grpc
test
scripts
state
test
types
version
.codecov.yml
.gitignore
INSTALL.md
LICENSE
Makefile
README.md
Vagrantfile
circle.yml
glide.lock
glide.yaml
tendermint/rpc/core/net.go

50 lines
1.3 KiB
Go
Raw Normal View History

package core
import (
"fmt"
ctypes "github.com/tendermint/tendermint/rpc/core/types"
)
//-----------------------------------------------------------------------------
func NetInfo() (*ctypes.ResultNetInfo, error) {
listening := p2pSwitch.IsListening()
listeners := []string{}
for _, listener := range p2pSwitch.Listeners() {
listeners = append(listeners, listener.String())
}
2015-04-17 18:22:44 -07:00
peers := []ctypes.Peer{}
for _, peer := range p2pSwitch.Peers().List() {
2015-04-17 18:22:44 -07:00
peers = append(peers, ctypes.Peer{
NodeInfo: *peer.NodeInfo,
IsOutbound: peer.IsOutbound(),
ConnectionStatus: peer.Connection().Status(),
2015-04-17 18:22:44 -07:00
})
}
return &ctypes.ResultNetInfo{
Listening: listening,
Listeners: listeners,
Peers: peers,
}, nil
}
//-----------------------------------------------------------------------------
// Dial given list of seeds if we have no outbound peers
func DialSeeds(seeds []string) (*ctypes.ResultDialSeeds, error) {
outbound, _, _ := p2pSwitch.NumPeers()
if outbound != 0 {
return nil, fmt.Errorf("Already have some outbound peers")
}
// starts go routines to dial each seed after random delays
p2pSwitch.DialSeeds(seeds)
return &ctypes.ResultDialSeeds{}, nil
}
//-----------------------------------------------------------------------------
func Genesis() (*ctypes.ResultGenesis, error) {
return &ctypes.ResultGenesis{genDoc}, nil
}