-
Notifications
You must be signed in to change notification settings - Fork 2
/
sbch_client.go
57 lines (47 loc) · 1.37 KB
/
sbch_client.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
56
57
package collector
import (
"context"
"time"
sbchclient "github.com/smartbch/smartbch/rpc/client"
sbchrpc "github.com/smartbch/smartbch/rpc/types"
)
const (
getTimeout = time.Second * 15
)
func getCcInfo(client *sbchclient.Client) (*sbchrpc.CcInfo, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), getTimeout)
defer cancelFn()
return client.CcInfo(ctx)
}
func getRedeemingUtxosForOperators(client *sbchclient.Client) ([]*sbchrpc.UtxoInfo, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), getTimeout)
defer cancelFn()
utxos, err := client.RedeemingUtxosForOperators(ctx)
if err != nil {
return nil, err
}
return utxos.Infos, nil
}
func getToBeConvertedUtxosForOperators(client *sbchclient.Client) ([]*sbchrpc.UtxoInfo, error) {
ctx, cancelFn := context.WithTimeout(context.Background(), getTimeout)
defer cancelFn()
utxos, err := client.ToBeConvertedUtxosForOperators(ctx)
if err != nil {
return nil, err
}
return utxos.Infos, nil
}
func getOperatorPubkeys(operators []*sbchrpc.OperatorInfo) [][]byte {
pubkeys := make([][]byte, len(operators))
for i, operator := range operators {
pubkeys[i] = operator.Pubkey
}
return pubkeys
}
func getMonitorPubkeys(monitors []*sbchrpc.MonitorInfo) [][]byte {
pubkeys := make([][]byte, len(monitors))
for i, monitor := range monitors {
pubkeys[i] = monitor.Pubkey
}
return pubkeys
}