github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/cmd/tendermint/main.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/ari-anchor/sei-tendermint/cmd/tendermint/commands"
     7  	"github.com/ari-anchor/sei-tendermint/cmd/tendermint/commands/debug"
     8  	"github.com/ari-anchor/sei-tendermint/config"
     9  	"github.com/ari-anchor/sei-tendermint/libs/cli"
    10  	"github.com/ari-anchor/sei-tendermint/libs/log"
    11  	"github.com/ari-anchor/sei-tendermint/node"
    12  )
    13  
    14  func main() {
    15  	ctx, cancel := context.WithCancel(context.Background())
    16  	defer cancel()
    17  
    18  	conf, err := commands.ParseConfig(config.DefaultConfig())
    19  	if err != nil {
    20  		panic(err)
    21  	}
    22  
    23  	logger, err := log.NewDefaultLogger(conf.LogFormat, conf.LogLevel)
    24  	if err != nil {
    25  		panic(err)
    26  	}
    27  
    28  	// A stop gap solution to restart the node for certain failures (such as network partition)
    29  	restartCh := make(chan struct{})
    30  
    31  	rcmd := commands.RootCommand(conf, logger)
    32  	rcmd.AddCommand(
    33  		commands.MakeGenValidatorCommand(),
    34  		commands.MakeReindexEventCommand(conf, logger),
    35  		commands.MakeInitFilesCommand(conf, logger),
    36  		commands.MakeLightCommand(conf, logger),
    37  		commands.MakeReplayCommand(conf, logger),
    38  		commands.MakeReplayConsoleCommand(conf, logger),
    39  		commands.MakeResetCommand(conf, logger),
    40  		commands.MakeUnsafeResetAllCommand(conf, logger),
    41  		commands.MakeShowValidatorCommand(conf, logger),
    42  		commands.MakeTestnetFilesCommand(conf, logger),
    43  		commands.MakeShowNodeIDCommand(conf),
    44  		commands.GenNodeKeyCmd,
    45  		commands.VersionCmd,
    46  		commands.MakeInspectCommand(conf, logger),
    47  		commands.MakeRollbackStateCommand(conf),
    48  		commands.MakeKeyMigrateCommand(conf, logger),
    49  		debug.GetDebugCommand(logger),
    50  		commands.NewCompletionCmd(rcmd, true),
    51  		commands.MakeCompactDBCommand(conf, logger),
    52  	)
    53  
    54  	// NOTE:
    55  	// Users wishing to:
    56  	//	* Use an external signer for their validators
    57  	//	* Supply an in-proc abci app
    58  	//	* Supply a genesis doc file from another source
    59  	//	* Provide their own DB implementation
    60  	// can copy this file and use something other than the
    61  	// node.NewDefault function
    62  	nodeFunc := node.NewDefault
    63  
    64  	// Create & start node
    65  	rcmd.AddCommand(commands.NewRunNodeCmd(nodeFunc, conf, logger, restartCh))
    66  
    67  	if err := cli.RunWithTrace(ctx, rcmd); err != nil {
    68  		panic(err)
    69  	}
    70  }