github.com/intfoundation/intchain@v0.0.0-20220727031208-4316ad31ca73/cmd/intchain/main.go (about) 1 // intchain is the official command-line client for INT Chain. 2 package main 3 4 import ( 5 "fmt" 6 "github.com/intfoundation/intchain/log" 7 "os" 8 "runtime" 9 "sort" 10 "time" 11 12 "github.com/intfoundation/intchain/cmd/utils" 13 "github.com/intfoundation/intchain/console" 14 "github.com/intfoundation/intchain/internal/debug" 15 "github.com/intfoundation/intchain/metrics" 16 "gopkg.in/urfave/cli.v1" 17 ) 18 19 const ( 20 clientIdentifier = "intchain" // Client identifier to advertise over the network 21 ) 22 23 var ( 24 // Git SHA1 commit hash of the release (set via linker flags) 25 gitCommit = "" 26 gitDate = "" 27 28 // The app that holds all commands and flags. 29 app = utils.NewApp(gitCommit, "the intchain command line interface") 30 // flags that configure the node 31 nodeFlags = []cli.Flag{ 32 utils.IdentityFlag, 33 utils.UnlockedAccountFlag, 34 utils.PasswordFileFlag, 35 utils.BootnodesFlag, 36 utils.BootnodesV4Flag, 37 utils.BootnodesV5Flag, 38 utils.DataDirFlag, 39 utils.KeyStoreDirFlag, 40 utils.NoUSBFlag, 41 utils.TxPoolNoLocalsFlag, 42 utils.TxPoolJournalFlag, 43 utils.TxPoolRejournalFlag, 44 utils.TxPoolPriceLimitFlag, 45 utils.TxPoolPriceBumpFlag, 46 utils.TxPoolAccountSlotsFlag, 47 utils.TxPoolGlobalSlotsFlag, 48 utils.TxPoolAccountQueueFlag, 49 utils.TxPoolGlobalQueueFlag, 50 utils.TxPoolLifetimeFlag, 51 //utils.FastSyncFlag, 52 utils.SyncModeFlag, 53 utils.GCModeFlag, 54 utils.CacheFlag, 55 utils.CacheDatabaseFlag, 56 utils.CacheTrieFlag, 57 utils.CacheGCFlag, 58 utils.ListenPortFlag, 59 utils.MaxPeersFlag, 60 utils.MaxPendingPeersFlag, 61 utils.MiningEnabledFlag, 62 utils.MinerThreadsFlag, 63 utils.MinerGasTargetFlag, 64 utils.MinerGasLimitFlag, 65 utils.MinerGasPriceFlag, 66 utils.MinerCoinbaseFlag, 67 utils.NATFlag, 68 utils.NoDiscoverFlag, 69 utils.DiscoveryV5Flag, 70 utils.NetrestrictFlag, 71 utils.NodeKeyFileFlag, 72 utils.NodeKeyHexFlag, 73 utils.TestnetFlag, 74 utils.VMEnableDebugFlag, 75 utils.NetworkIdFlag, 76 utils.RPCCORSDomainFlag, 77 utils.RPCVirtualHostsFlag, 78 //utils.EthStatsURLFlag, 79 utils.MetricsEnabledFlag, 80 utils.NoCompactionFlag, 81 utils.GpoBlocksFlag, 82 utils.GpoPercentileFlag, 83 utils.ExtraDataFlag, 84 //configFileFlag, 85 86 //utils.LogDirFlag, 87 utils.ChildChainFlag, 88 } 89 90 rpcFlags = []cli.Flag{ 91 utils.RPCEnabledFlag, 92 utils.RPCListenAddrFlag, 93 utils.RPCPortFlag, 94 utils.RPCApiFlag, 95 utils.WSEnabledFlag, 96 utils.WSListenAddrFlag, 97 utils.WSPortFlag, 98 utils.WSApiFlag, 99 utils.WSAllowedOriginsFlag, 100 utils.IPCDisabledFlag, 101 utils.IPCPathFlag, 102 } 103 ) 104 105 func init() { 106 // Initialize the CLI app and start intchain 107 app.Action = intchainCmd 108 app.HideVersion = true // we have a command to print the version 109 app.Copyright = "Copyright 2017-2021 The INT Chain Authors" 110 app.Commands = []cli.Command{ 111 // See chaincmd.go: 112 createValidatorCmd, 113 initINTGenesisCmd, 114 initCommand, 115 //initChildChainCmd, 116 importCommand, 117 exportCommand, 118 copydbCommand, 119 removedbCommand, 120 dumpCommand, 121 // See monitorcmd.go: 122 monitorCommand, 123 // See accountcmd.go: 124 accountCommand, 125 //walletCommand, 126 // See consolecmd.go: 127 consoleCommand, 128 attachCommand, 129 javascriptCommand, 130 // See misccmd.go: 131 132 bugCommand, 133 // See config.go 134 dumpConfigCommand, 135 versionCommand, 136 } 137 sort.Sort(cli.CommandsByName(app.Commands)) 138 139 app.Flags = append(app.Flags, nodeFlags...) 140 app.Flags = append(app.Flags, rpcFlags...) 141 app.Flags = append(app.Flags, consoleFlags...) 142 app.Flags = append(app.Flags, debug.Flags...) 143 144 app.Before = func(ctx *cli.Context) error { 145 runtime.GOMAXPROCS(runtime.NumCPU()) 146 147 // Setup the Global Logger 148 149 log.NewLogger("", "", ctx.GlobalInt("verbosity"), ctx.GlobalBool("debug"), ctx.GlobalString("vmodule"), ctx.GlobalString("backtrace")) 150 151 if err := debug.Setup(ctx); err != nil { 152 return err 153 } 154 155 // Start system runtime metrics collection 156 go metrics.CollectProcessMetrics(3 * time.Second) 157 158 return nil 159 } 160 161 app.After = func(ctx *cli.Context) error { 162 debug.Exit() 163 console.Stdin.Close() // Resets terminal mode. 164 return nil 165 } 166 } 167 168 func main() { 169 if err := app.Run(os.Args); err != nil { 170 fmt.Fprintln(os.Stderr, err) 171 os.Exit(1) 172 } 173 }