-
Notifications
You must be signed in to change notification settings - Fork 1
/
query.go
91 lines (78 loc) · 1.92 KB
/
query.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package commands
import (
"fmt"
"os"
rtypes "github.com/assetcloud/plugin/plugin/dapp/rollup/types"
"github.com/spf13/cobra"
)
func validatorCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "validator",
Short: "show validators bls pubkey",
Run: getValidator,
}
addTitleFlags(cmd)
return cmd
}
func addTitleFlags(cmd *cobra.Command) {
cmd.Flags().StringP("paratitle", "t", "", "para chain title")
markRequired(cmd, "paratitle")
}
func getValidator(cmd *cobra.Command, args []string) {
title, _ := cmd.Flags().GetString("paratitle")
if title == "" {
fmt.Fprintf(os.Stderr, "Err empty parachain title")
return
}
params := &rtypes.ChainTitle{
Value: title,
}
info := &rtypes.ValidatorPubs{}
sendQueryRPC(cmd, "GetValidatorPubs", params, info)
}
func rollupStatusCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "show rollup status",
Run: getRollupStatus,
}
addTitleFlags(cmd)
return cmd
}
func getRollupStatus(cmd *cobra.Command, args []string) {
title, _ := cmd.Flags().GetString("paratitle")
if title == "" {
fmt.Fprintf(os.Stderr, "Err empty parachain title")
return
}
params := &rtypes.ChainTitle{
Value: title,
}
info := &rtypes.RollupStatus{}
sendQueryRPC(cmd, "GetRollupStatus", params, info)
}
func roundInfoCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "round",
Short: "show rollup commit round info",
Run: getRoundInfo,
}
addTitleFlags(cmd)
cmd.Flags().Int64P("round", "r", 0, "commit round")
markRequired(cmd, "round")
return cmd
}
func getRoundInfo(cmd *cobra.Command, args []string) {
title, _ := cmd.Flags().GetString("paratitle")
if title == "" {
fmt.Fprintf(os.Stderr, "Err empty parachain title")
return
}
round, _ := cmd.Flags().GetInt64("round")
params := &rtypes.ReqGetCommitRound{
ChainTitle: title,
CommitRound: round,
}
info := &rtypes.CommitRoundInfo{}
sendQueryRPC(cmd, "GetCommitRoundInfo", params, info)
}