-
Notifications
You must be signed in to change notification settings - Fork 0
/
ibft_snapshot.go
48 lines (37 loc) · 968 Bytes
/
ibft_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
package snapshot
import (
"github.com/metaplayer-one/metad/command"
"github.com/metaplayer-one/metad/command/helper"
"github.com/spf13/cobra"
)
func GetCommand() *cobra.Command {
ibftSnapshotCmd := &cobra.Command{
Use: "snapshot",
Short: "Returns the IBFT snapshot at the latest block number, unless a block number is specified",
Run: runCommand,
}
setFlags(ibftSnapshotCmd)
return ibftSnapshotCmd
}
func setFlags(cmd *cobra.Command) {
cmd.Flags().IntVar(
¶ms.blockNumber,
numberFlag,
-1,
"the block height (number) for the snapshot",
)
}
func runCommand(cmd *cobra.Command, _ []string) {
outputter := command.InitializeOutputter(cmd)
defer outputter.WriteOutput()
if err := params.initSnapshot(helper.GetGRPCAddress(cmd)); err != nil {
outputter.SetError(err)
return
}
result, err := newIBFTSnapshotResult(params.snapshot)
if err != nil {
outputter.SetError(err)
return
}
outputter.SetCommandResult(result)
}