github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/chain/neatio/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 "runtime" 7 "sort" 8 "time" 9 10 "github.com/neatio-net/neatio/chain/log" 11 12 "github.com/neatio-net/neatio/internal/debug" 13 "github.com/neatio-net/neatio/utilities/console" 14 "github.com/neatio-net/neatio/utilities/metrics" 15 "github.com/neatio-net/neatio/utilities/utils" 16 "gopkg.in/urfave/cli.v1" 17 ) 18 19 const ( 20 clientIdentifier = "neatio" 21 ) 22 23 var ( 24 gitCommit = "" 25 gitDate = "" 26 27 app = utils.NewApp(gitCommit, "the neatio command line interface") 28 29 nodeFlags = []cli.Flag{ 30 utils.IdentityFlag, 31 utils.UnlockedAccountFlag, 32 utils.PasswordFileFlag, 33 utils.BootnodesFlag, 34 utils.BootnodesV4Flag, 35 utils.BootnodesV5Flag, 36 utils.DataDirFlag, 37 utils.KeyStoreDirFlag, 38 utils.NoUSBFlag, 39 utils.TxPoolNoLocalsFlag, 40 utils.TxPoolJournalFlag, 41 utils.TxPoolRejournalFlag, 42 utils.TxPoolPriceLimitFlag, 43 utils.TxPoolPriceBumpFlag, 44 utils.TxPoolAccountSlotsFlag, 45 utils.TxPoolGlobalSlotsFlag, 46 utils.TxPoolAccountQueueFlag, 47 utils.TxPoolGlobalQueueFlag, 48 utils.TxPoolLifetimeFlag, 49 50 utils.SyncModeFlag, 51 utils.GCModeFlag, 52 utils.CacheFlag, 53 utils.CacheDatabaseFlag, 54 utils.CacheTrieFlag, 55 utils.CacheGCFlag, 56 utils.ListenPortFlag, 57 utils.MaxPeersFlag, 58 utils.MaxPendingPeersFlag, 59 utils.MiningEnabledFlag, 60 utils.MinerThreadsFlag, 61 utils.MinerGasTargetFlag, 62 utils.MinerGasLimitFlag, 63 utils.MinerGasPriceFlag, 64 utils.MinerCoinbaseFlag, 65 utils.NATFlag, 66 utils.NoDiscoverFlag, 67 utils.DiscoveryV5Flag, 68 utils.NetrestrictFlag, 69 utils.NodeKeyFileFlag, 70 utils.NodeKeyHexFlag, 71 utils.TestnetFlag, 72 utils.VMEnableDebugFlag, 73 utils.NetworkIdFlag, 74 utils.RPCCORSDomainFlag, 75 utils.RPCVirtualHostsFlag, 76 77 utils.MetricsEnabledFlag, 78 utils.NoCompactionFlag, 79 utils.GpoBlocksFlag, 80 utils.GpoPercentileFlag, 81 utils.ExtraDataFlag, 82 83 utils.SideChainFlag, 84 } 85 86 rpcFlags = []cli.Flag{ 87 utils.RPCEnabledFlag, 88 utils.RPCListenAddrFlag, 89 utils.RPCPortFlag, 90 utils.RPCApiFlag, 91 utils.WSEnabledFlag, 92 utils.WSListenAddrFlag, 93 utils.WSPortFlag, 94 utils.WSApiFlag, 95 utils.WSAllowedOriginsFlag, 96 utils.IPCDisabledFlag, 97 utils.IPCPathFlag, 98 } 99 ) 100 101 func init() { 102 103 app.Action = neatchainCmd 104 app.HideVersion = true 105 app.Copyright = "Copyright 2022 Neatio Developers" 106 app.Commands = []cli.Command{ 107 108 createValidatorCmd, 109 initNEATGenesisCmd, 110 initCommand, 111 112 importCommand, 113 exportCommand, 114 copydbCommand, 115 removedbCommand, 116 dumpCommand, 117 118 monitorCommand, 119 120 accountCommand, 121 122 consoleCommand, 123 attachCommand, 124 javascriptCommand, 125 126 bugCommand, 127 128 dumpConfigCommand, 129 versionCommand, 130 } 131 sort.Sort(cli.CommandsByName(app.Commands)) 132 133 app.Flags = append(app.Flags, nodeFlags...) 134 app.Flags = append(app.Flags, rpcFlags...) 135 app.Flags = append(app.Flags, consoleFlags...) 136 app.Flags = append(app.Flags, debug.Flags...) 137 138 app.Before = func(ctx *cli.Context) error { 139 runtime.GOMAXPROCS(runtime.NumCPU()) 140 141 log.NewLogger("", "", ctx.GlobalInt("verbosity"), ctx.GlobalBool("debug"), ctx.GlobalString("vmodule"), ctx.GlobalString("backtrace")) 142 143 if err := debug.Setup(ctx); err != nil { 144 return err 145 } 146 147 go metrics.CollectProcessMetrics(3 * time.Second) 148 149 return nil 150 } 151 152 app.After = func(ctx *cli.Context) error { 153 debug.Exit() 154 console.Stdin.Close() 155 return nil 156 } 157 } 158 159 func main() { 160 if err := app.Run(os.Args); err != nil { 161 fmt.Fprintln(os.Stderr, err) 162 os.Exit(1) 163 } 164 }