/
main.go
54 lines (47 loc) · 1.69 KB
/
main.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
package main
import (
"github.com/holiman/uint256"
"github.com/spf13/cobra"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
"github.com/tendermint/tendermint/libs/log"
"github.com/superbch/superbch/app"
"github.com/superbch/superbch/param"
)
type AppCreator func(logger log.Logger, chainId *uint256.Int, config *param.ChainConfig) abci.Application
func main() {
rootCmd := createSuperbchdCmd()
executor := cli.PrepareBaseCmd(rootCmd, "GA", DefaultNodeHome)
err := executor.Execute()
if err != nil {
// handle with #870
panic(err)
}
}
func createSuperbchdCmd() *cobra.Command {
cobra.EnableCommandSorting = false
ctx := NewDefaultContext()
rootCmd := &cobra.Command{
Use: "superbchd",
Short: "SuperBCH Chain Daemon (server)",
PersistentPreRunE: PersistentPreRunEFn(ctx),
}
addInitCommands(ctx, rootCmd)
rootCmd.AddCommand(StartCmd(ctx, newApp))
rootCmd.AddCommand(ConfigCmd(DefaultNodeHome))
rootCmd.AddCommand(GenerateConsensusKeyInfoCmd(ctx))
rootCmd.AddCommand(GenerateGenesisValidatorCmd(ctx))
rootCmd.AddCommand(AddGenesisValidatorCmd(ctx))
rootCmd.AddCommand(StakingCmd(ctx))
rootCmd.AddCommand(VersionCmd())
return rootCmd
}
func addInitCommands(ctx *Context, rootCmd *cobra.Command) {
initCmd := InitCmd(ctx, DefaultNodeHome)
genTestKeysCmd := GenTestKeysCmd(ctx)
rootCmd.AddCommand(initCmd, genTestKeysCmd)
}
func newApp(logger log.Logger, chainId *uint256.Int, config *param.ChainConfig) abci.Application {
return app.NewApp(config, chainId, viper.GetInt64(flagGenesisMainnetHeight), viper.GetInt64(flagCCGenesisMainnetHeight), logger, viper.GetBool(flagSkipSanityCheck))
}