add a call to admin_nodeInfo before launching gui
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
2bc143aa2b
commit
8bfea2f8b3
|
@ -16,6 +16,15 @@ func newClient(url string) (*StatusGoClient, error) {
|
||||||
return &StatusGoClient{rpcClient}, nil
|
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) getPeers() ([]Peer, error) {
|
func (c *StatusGoClient) getPeers() ([]Peer, error) {
|
||||||
var peers []Peer
|
var peers []Peer
|
||||||
err := c.rpcClient.Call(&peers, "admin_peers")
|
err := c.rpcClient.Call(&peers, "admin_peers")
|
||||||
|
|
27
json.go
27
json.go
|
@ -2,9 +2,30 @@ package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
type NodeInfo struct {
|
||||||
|
Enode string `json:"enode"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
ID PeerID `json:"id"`
|
||||||
|
ListenIp string `json:"ip"`
|
||||||
|
ListenAddr string `json:"listenAddr"`
|
||||||
|
ListenPorts NodeInfoPorts `json:"ports"`
|
||||||
|
Protocols map[string]NodeProtocol `json:"protocols"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NodeInfoPorts struct {
|
||||||
|
Discovery int `json:"discovert"`
|
||||||
|
Listener int `json:"listener"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type NodeProtocol struct {
|
||||||
|
MaxMessageSize int `json:"maxMessageSize"`
|
||||||
|
MinimumPoW float32 `json:"minimumPoW"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
}
|
||||||
|
|
||||||
type Peer struct {
|
type Peer struct {
|
||||||
Enode string `json:"enode"`
|
Enode string `json:"enode"`
|
||||||
ID PeerId `json:"id"`
|
ID PeerID `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Caps []string `json:"caps"`
|
Caps []string `json:"caps"`
|
||||||
Network NetworkInfo `json:"network"`
|
Network NetworkInfo `json:"network"`
|
||||||
|
@ -15,10 +36,10 @@ func (p Peer) String() string {
|
||||||
return fmt.Sprintf("Peer(ID=%s)", p.ID)
|
return fmt.Sprintf("Peer(ID=%s)", p.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeerId string
|
type PeerID string
|
||||||
|
|
||||||
// the ID is too long to display in full in most places
|
// the ID is too long to display in full in most places
|
||||||
func (id PeerId) String() string {
|
func (id PeerID) String() string {
|
||||||
return fmt.Sprintf("%s...%s",
|
return fmt.Sprintf("%s...%s",
|
||||||
string(id[:6]),
|
string(id[:6]),
|
||||||
string(id[len(id)-6:]))
|
string(id[len(id)-6:]))
|
||||||
|
|
8
main.go
8
main.go
|
@ -39,6 +39,14 @@ func main() {
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify the RPC endpoint is available first
|
||||||
|
node, err := client.nodeInfo()
|
||||||
|
if err != nil {
|
||||||
|
log.Panicln(err)
|
||||||
|
}
|
||||||
|
log.Println("Successful connection to:", url)
|
||||||
|
log.Println("Enode:", node.Enode)
|
||||||
|
|
||||||
// Create a state wrapper.
|
// Create a state wrapper.
|
||||||
state := NewState(client)
|
state := NewState(client)
|
||||||
// Subscribe rendering method to state changes.
|
// Subscribe rendering method to state changes.
|
||||||
|
|
Loading…
Reference in New Issue