-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibft_status.go
45 lines (37 loc) · 1.02 KB
/
ibft_status.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
package status
import (
"context"
"github.com/Coinmaxify/Coinmaxify/command"
"github.com/Coinmaxify/Coinmaxify/command/helper"
ibftOp "github.com/Coinmaxify/Coinmaxify/consensus/ibft/proto"
"github.com/spf13/cobra"
empty "google.golang.org/protobuf/types/known/emptypb"
)
func GetCommand() *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Returns the current validator key of the IBFT client",
Run: runCommand,
}
}
func runCommand(cmd *cobra.Command, _ []string) {
outputter := command.InitializeOutputter(cmd)
defer outputter.WriteOutput()
statusResponse, err := getIBFTStatus(helper.GetGRPCAddress(cmd))
if err != nil {
outputter.SetError(err)
return
}
outputter.SetCommandResult(&IBFTStatusResult{
ValidatorKey: statusResponse.Key,
})
}
func getIBFTStatus(grpcAddress string) (*ibftOp.IbftStatusResp, error) {
client, err := helper.GetIBFTOperatorClientConnection(
grpcAddress,
)
if err != nil {
return nil, err
}
return client.Status(context.Background(), &empty.Empty{})
}