From 9d236b298ac2d33ef8c98bb64f405bc45abd911e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Wed, 3 Jul 2019 15:25:22 -0400 Subject: [PATCH] simplify rcp call methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- client.go | 40 ++++++++++++---------------------------- control.go | 2 +- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/client.go b/client.go index 3a7c6e3..3614d50 100644 --- a/client.go +++ b/client.go @@ -16,38 +16,22 @@ func newClient(url string) (*StatusGoClient, error) { return &StatusGoClient{rpcClient}, nil } -func (c *StatusGoClient) nodeInfo() (*NodeInfo, error) { - var info NodeInfo - err := c.rpcClient.Call(&info, "admin_nodeInfo") - if err != nil { - return nil, err - } - return &info, nil +func (c *StatusGoClient) nodeInfo() (info NodeInfo, err error) { + err = c.rpcClient.Call(&info, "admin_nodeInfo") + return } -func (c *StatusGoClient) getPeers() ([]Peer, error) { - var peers []Peer - err := c.rpcClient.Call(&peers, "admin_peers") - if err != nil { - return nil, err - } - return peers, nil +func (c *StatusGoClient) getPeers() (peers []Peer, err error) { + err = c.rpcClient.Call(&peers, "admin_peers") + return } -func (c *StatusGoClient) removePeer(enode string) (bool, error) { - var rval bool - err := c.rpcClient.Call(&rval, "admin_removePeer", enode) - if err != nil { - return false, err - } - return rval, nil +func (c *StatusGoClient) removePeer(enode string) (success bool, err error) { + err = c.rpcClient.Call(&success, "admin_removePeer", enode) + return } -func (c *StatusGoClient) trustPeer(enode string) (bool, error) { - var rval bool - err := c.rpcClient.Call(&rval, "shh_markTrustedPeer", enode) - if err != nil { - return false, err - } - return rval, nil +func (c *StatusGoClient) trustPeer(enode string) (success bool, err error) { + err = c.rpcClient.Call(&success, "shh_markTrustedPeer", enode) + return } diff --git a/control.go b/control.go index 56de1ac..a9e08a5 100644 --- a/control.go +++ b/control.go @@ -46,6 +46,6 @@ func (s *StateController) GetInfo() error { if err != nil { return err } - s.State.UpdateInfo(*info) + s.State.UpdateInfo(info) return nil }