-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapshot.go
50 lines (44 loc) · 1.37 KB
/
snapshot.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
package kernel
import "encoding/json"
type References struct {
External string `json:"external"`
Self string `json:"self"`
}
type Witness struct {
Signature string `json:"signature"`
Timestamp int64 `json:"timestamp"`
}
type SnapshotWithTransaction struct {
Hash string `json:"hash"`
Hex string `json:"hex"`
Node string `json:"node"`
References *References `json:"references"`
Round int64 `json:"round"`
Signature string `json:"signature"`
Timestamp uint64 `json:"timestamp"`
Topology uint64 `json:"topology"`
Transactions []*Transaction `json:"transactions"`
Version uint8 `json:"version"`
Witness *Witness `json:"witness"`
}
func (m *MixinNetwork) GetSnapshot(hash string) (*SnapshotWithTransaction, error) {
b, err := m.callRPC("getsnapshot", []any{hash})
if err != nil || b == nil {
return nil, err
}
var s SnapshotWithTransaction
err = json.Unmarshal(b, &s)
if err != nil {
return nil, err
}
return &s, err
}
func (m *MixinNetwork) ListSnapshotsSince(since, count, sig, tx uint64) ([]*SnapshotWithTransaction, error) {
body, err := m.callRPC("listsnapshots", []any{since, count, sig, tx})
if err != nil {
return nil, err
}
var snapshots []*SnapshotWithTransaction
err = json.Unmarshal(body, &snapshots)
return snapshots, err
}