2019-06-16 16:02:50 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-06-20 21:01:34 +00:00
|
|
|
func (c *client) getPeers() ([]Peer, error) {
|
|
|
|
peers := make([]Peer, 0)
|
|
|
|
err := c.rpcClient.Call(&peers, "admin_peers")
|
2019-06-16 16:02:50 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-06-20 21:01:34 +00:00
|
|
|
return peers, nil
|
2019-06-16 16:02:50 +00:00
|
|
|
}
|