status-go-monitor/client.go
Jakub Sokołowski c6b3fa3b9d add displaying of list of peers
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2019-07-01 13:07:20 -04:00

27 lines
443 B
Go

package main
import (
"github.com/ethereum/go-ethereum/rpc"
)
type client struct {
rpcClient *rpc.Client
}
func newClient(url string) (*client, error) {
rpcClient, err := rpc.Dial(url)
if err != nil {
return nil, err
}
return &client{rpcClient}, nil
}
func (c *client) getPeers() ([]Peer, error) {
peers := make([]Peer, 0)
err := c.rpcClient.Call(&peers, "admin_peers")
if err != nil {
return nil, err
}
return peers, nil
}