Skip to content

Commit

Permalink
refactor: naet.Node.Info() returns netowrkID and node version for use…
Browse files Browse the repository at this point in the history
… with HLL
  • Loading branch information
randomshinichi committed Jan 21, 2020
1 parent 2fa3dbb commit 6601570
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions naet/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,27 @@ func urlComponents(url string) (host string, schemas []string) {
// NewNode instantiates a new swagger HTTP client to an aeternity node. No
// network connection is actually performed, this only sets up the HTTP client
// code.
func NewNode(nodeURL string, debug bool) *Node {
func NewNode(nodeURL string, debug bool) (aecli *Node) {
// create the transport
host, schemas := urlComponents(nodeURL)
transport := httptransport.New(host, "/v2", schemas)
transport.SetDebug(debug)
// create the API client, with the transport
openAPIClient := apiclient.New(transport, strfmt.Default)
aecli := &Node{
aecli = &Node{
Node: openAPIClient,
}
return aecli
return
}

type Infoer interface {
Info() (networkID string, version string)
}

func (n *Node) Info() (networkID string, version string) {
s, err := n.GetStatus()
if err != nil {
return
}
return *s.NetworkID, *s.NodeVersion
}

0 comments on commit 6601570

Please sign in to comment.