-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet.go
41 lines (30 loc) · 1.14 KB
/
net.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package eosrpc
import "github.com/TheBoringDude/go-urljoin"
const NET_API = "net"
// Connections returns an array of all peer connection statuses.
func (n *NetAPI) Connections() (NetConnectionsResponse, error) {
var r = NetConnectionsResponse{}
err := request(n.Client, urljoin.UrlJoin(n.ApiUrl, "connections"), nil, &r)
return r, err
}
type NetConnectProps struct {
Endpoint string `json:"endpoint"`
}
// Connect initiates a connection to a specified peer.
func (n *NetAPI) Connect(props NetConnectProps) (string, error) {
var r = ""
err := request(n.Client, urljoin.UrlJoin(n.ApiUrl, "connect"), props, &r)
return r, err
}
// Disconnect initiates a diconnection to a specified peer.
func (n *NetAPI) Disconnect(props NetConnectProps) (string, error) {
var r = ""
err := request(n.Client, urljoin.UrlJoin(n.ApiUrl, "disconnect"), props, &r)
return r, err
}
// Status retrieves the connection status for a specified peer.
func (n *NetAPI) Status(props NetConnectProps) (NetConnectionsResponseElement, error) {
var r = NetConnectionsResponseElement{}
err := request(n.Client, urljoin.UrlJoin(n.ApiUrl, "disconnect"), props, &r)
return r, err
}