-
Notifications
You must be signed in to change notification settings - Fork 507
/
ibft_quorum.go
62 lines (48 loc) · 1.24 KB
/
ibft_quorum.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
package quorum
import (
"fmt"
"github.com/0xPolygon/polygon-edge/command"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/spf13/cobra"
)
func GetCommand() *cobra.Command {
ibftQuorumCmd := &cobra.Command{
Use: "quorum",
Short: "Specify the block number after which quorum optimal will be used for reaching consensus",
PreRunE: runPreRun,
Run: runCommand,
}
setFlags(ibftQuorumCmd)
helper.SetRequiredFlags(ibftQuorumCmd, params.getRequiredFlags())
return ibftQuorumCmd
}
func setFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
¶ms.genesisPath,
chainFlag,
fmt.Sprintf("./%s", command.DefaultGenesisFileName),
"the genesis file to update",
)
cmd.Flags().Uint64Var(
¶ms.from,
fromFlag,
0,
"the height to switch the quorum calculation",
)
}
func runPreRun(_ *cobra.Command, _ []string) error {
return params.initRawParams()
}
func runCommand(cmd *cobra.Command, _ []string) {
outputter := command.InitializeOutputter(cmd)
defer outputter.WriteOutput()
if err := params.updateGenesisConfig(); err != nil {
outputter.SetError(err)
return
}
if err := params.overrideGenesisConfig(); err != nil {
outputter.SetError(err)
return
}
outputter.SetCommandResult(params.getResult())
}