-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.go
55 lines (48 loc) · 1.32 KB
/
node.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package kernel
import "encoding/json"
type Node struct {
ID string `json:"id"`
Payee string `json:"payee"`
Signer string `json:"signer"`
State string `json:"state"`
Timestamp int64 `json:"timestamp"`
Transaction string `json:"transaction"`
}
func (m *MixinNetwork) ListAllNodes() ([]*Node, error) {
b, err := m.callRPC("listallnodes", []any{0, false})
if err != nil || b == nil {
return nil, err
}
var n []*Node
err = json.Unmarshal(b, &n)
return n, err
}
type Reference struct {
External string `json:"external"`
Self string `json:"self"`
}
type Snapshot struct {
Hash string `json:"hash"`
Timestamp int64 `json:"timestamp"`
Topology int64 `json:"topology"`
Transactions []string `json:"transactions"`
Version int `json:"version"`
}
type Round struct {
End int `json:"end"`
Hash string `json:"hash"`
Node string `json:"node"`
Number int `json:"number"`
References Reference `json:"references"`
Snapshots []*Snapshot `json:"snapshots"`
Start int `json:"start"`
}
func (m *MixinNetwork) GetRoundByHash(x string) (*Round, error) {
b, err := m.callRPC("getroundbyhash", []any{x})
if err != nil || b == nil {
return nil, err
}
var r Round
err = json.Unmarshal(b, &r)
return &r, err
}