2019-06-16 16:02:50 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/ethereum/go-ethereum/rpc"
|
|
|
|
)
|
|
|
|
|
2019-06-27 18:21:51 +00:00
|
|
|
type StatusGoClient struct {
|
2019-06-16 16:02:50 +00:00
|
|
|
rpcClient *rpc.Client
|
|
|
|
}
|
|
|
|
|
2019-06-27 18:21:51 +00:00
|
|
|
func newClient(url string) (*StatusGoClient, error) {
|
2019-06-16 16:02:50 +00:00
|
|
|
rpcClient, err := rpc.Dial(url)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-06-27 18:21:51 +00:00
|
|
|
return &StatusGoClient{rpcClient}, nil
|
2019-06-16 16:02:50 +00:00
|
|
|
}
|
|
|
|
|
2019-07-03 19:25:22 +00:00
|
|
|
func (c *StatusGoClient) nodeInfo() (info NodeInfo, err error) {
|
|
|
|
err = c.rpcClient.Call(&info, "admin_nodeInfo")
|
|
|
|
return
|
2019-07-01 20:35:44 +00:00
|
|
|
}
|
|
|
|
|
2019-07-03 19:25:22 +00:00
|
|
|
func (c *StatusGoClient) getPeers() (peers []Peer, err error) {
|
|
|
|
err = c.rpcClient.Call(&peers, "admin_peers")
|
|
|
|
return
|
2019-06-16 16:02:50 +00:00
|
|
|
}
|
2019-06-27 13:14:28 +00:00
|
|
|
|
2019-07-03 19:25:22 +00:00
|
|
|
func (c *StatusGoClient) removePeer(enode string) (success bool, err error) {
|
|
|
|
err = c.rpcClient.Call(&success, "admin_removePeer", enode)
|
|
|
|
return
|
2019-06-27 13:14:28 +00:00
|
|
|
}
|
2019-07-03 19:21:27 +00:00
|
|
|
|
2019-07-03 19:25:22 +00:00
|
|
|
func (c *StatusGoClient) trustPeer(enode string) (success bool, err error) {
|
|
|
|
err = c.rpcClient.Call(&success, "shh_markTrustedPeer", enode)
|
|
|
|
return
|
2019-07-03 19:21:27 +00:00
|
|
|
}
|