github.com/phillinzzz/newBsc@v1.1.6/cmd/geth/usage.go (about)

     1  // Copyright 2015 The go-ethereum Authors
     2  // This file is part of go-ethereum.
     3  //
     4  // go-ethereum is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // go-ethereum is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU General Public License
    15  // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  // Contains the geth command usage template and generator.
    18  
    19  package main
    20  
    21  import (
    22  	"io"
    23  	"sort"
    24  
    25  	"github.com/phillinzzz/newBsc/cmd/utils"
    26  	"github.com/phillinzzz/newBsc/internal/debug"
    27  	"github.com/phillinzzz/newBsc/internal/flags"
    28  	"gopkg.in/urfave/cli.v1"
    29  )
    30  
    31  // AppHelpFlagGroups is the application flags, grouped by functionality.
    32  var AppHelpFlagGroups = []flags.FlagGroup{
    33  	{
    34  		Name: "ETHEREUM",
    35  		Flags: []cli.Flag{
    36  			configFileFlag,
    37  			utils.DataDirFlag,
    38  			utils.AncientFlag,
    39  			utils.MinFreeDiskSpaceFlag,
    40  			utils.KeyStoreDirFlag,
    41  			utils.NoUSBFlag,
    42  			utils.DirectBroadcastFlag,
    43  			utils.DisableSnapProtocolFlag,
    44  			utils.RangeLimitFlag,
    45  			utils.SmartCardDaemonPathFlag,
    46  			utils.NetworkIdFlag,
    47  			utils.MainnetFlag,
    48  			utils.GoerliFlag,
    49  			utils.RinkebyFlag,
    50  			utils.YoloV3Flag,
    51  			utils.RopstenFlag,
    52  			utils.SyncModeFlag,
    53  			utils.ExitWhenSyncedFlag,
    54  			utils.GCModeFlag,
    55  			utils.TxLookupLimitFlag,
    56  			utils.EthStatsURLFlag,
    57  			utils.IdentityFlag,
    58  			utils.LightKDFFlag,
    59  			utils.WhitelistFlag,
    60  			utils.TriesInMemoryFlag,
    61  		},
    62  	},
    63  	{
    64  		Name: "LIGHT CLIENT",
    65  		Flags: []cli.Flag{
    66  			utils.LightServeFlag,
    67  			utils.LightIngressFlag,
    68  			utils.LightEgressFlag,
    69  			utils.LightMaxPeersFlag,
    70  			utils.UltraLightServersFlag,
    71  			utils.UltraLightFractionFlag,
    72  			utils.UltraLightOnlyAnnounceFlag,
    73  			utils.LightNoPruneFlag,
    74  			utils.LightNoSyncServeFlag,
    75  		},
    76  	},
    77  	{
    78  		Name: "DEVELOPER CHAIN",
    79  		Flags: []cli.Flag{
    80  			utils.DeveloperFlag,
    81  			utils.DeveloperPeriodFlag,
    82  		},
    83  	},
    84  	{
    85  		Name: "ETHASH",
    86  		Flags: []cli.Flag{
    87  			utils.EthashCacheDirFlag,
    88  			utils.EthashCachesInMemoryFlag,
    89  			utils.EthashCachesOnDiskFlag,
    90  			utils.EthashCachesLockMmapFlag,
    91  			utils.EthashDatasetDirFlag,
    92  			utils.EthashDatasetsInMemoryFlag,
    93  			utils.EthashDatasetsOnDiskFlag,
    94  			utils.EthashDatasetsLockMmapFlag,
    95  		},
    96  	},
    97  	{
    98  		Name: "TRANSACTION POOL",
    99  		Flags: []cli.Flag{
   100  			utils.TxPoolLocalsFlag,
   101  			utils.TxPoolNoLocalsFlag,
   102  			utils.TxPoolJournalFlag,
   103  			utils.TxPoolRejournalFlag,
   104  			utils.TxPoolPriceLimitFlag,
   105  			utils.TxPoolPriceBumpFlag,
   106  			utils.TxPoolAccountSlotsFlag,
   107  			utils.TxPoolGlobalSlotsFlag,
   108  			utils.TxPoolAccountQueueFlag,
   109  			utils.TxPoolGlobalQueueFlag,
   110  			utils.TxPoolLifetimeFlag,
   111  		},
   112  	},
   113  	{
   114  		Name: "PERFORMANCE TUNING",
   115  		Flags: []cli.Flag{
   116  			utils.CacheFlag,
   117  			utils.CacheDatabaseFlag,
   118  			utils.CacheTrieFlag,
   119  			utils.CacheTrieJournalFlag,
   120  			utils.CacheTrieRejournalFlag,
   121  			utils.CacheGCFlag,
   122  			utils.CacheSnapshotFlag,
   123  			utils.CachePreimagesFlag,
   124  		},
   125  	},
   126  	{
   127  		Name: "ACCOUNT",
   128  		Flags: []cli.Flag{
   129  			utils.UnlockedAccountFlag,
   130  			utils.PasswordFileFlag,
   131  			utils.ExternalSignerFlag,
   132  			utils.InsecureUnlockAllowedFlag,
   133  		},
   134  	},
   135  	{
   136  		Name: "API AND CONSOLE",
   137  		Flags: []cli.Flag{
   138  			utils.IPCDisabledFlag,
   139  			utils.IPCPathFlag,
   140  			utils.HTTPEnabledFlag,
   141  			utils.HTTPListenAddrFlag,
   142  			utils.HTTPPortFlag,
   143  			utils.HTTPApiFlag,
   144  			utils.HTTPPathPrefixFlag,
   145  			utils.HTTPCORSDomainFlag,
   146  			utils.HTTPVirtualHostsFlag,
   147  			utils.WSEnabledFlag,
   148  			utils.WSListenAddrFlag,
   149  			utils.WSPortFlag,
   150  			utils.WSApiFlag,
   151  			utils.WSPathPrefixFlag,
   152  			utils.WSAllowedOriginsFlag,
   153  			utils.GraphQLEnabledFlag,
   154  			utils.GraphQLCORSDomainFlag,
   155  			utils.GraphQLVirtualHostsFlag,
   156  			utils.RPCGlobalGasCapFlag,
   157  			utils.RPCGlobalTxFeeCapFlag,
   158  			utils.AllowUnprotectedTxs,
   159  			utils.JSpathFlag,
   160  			utils.ExecFlag,
   161  			utils.PreloadJSFlag,
   162  		},
   163  	},
   164  	{
   165  		Name: "NETWORKING",
   166  		Flags: []cli.Flag{
   167  			utils.BootnodesFlag,
   168  			utils.DNSDiscoveryFlag,
   169  			utils.ListenPortFlag,
   170  			utils.MaxPeersFlag,
   171  			utils.MaxPendingPeersFlag,
   172  			utils.NATFlag,
   173  			utils.NoDiscoverFlag,
   174  			utils.DiscoveryV5Flag,
   175  			utils.NetrestrictFlag,
   176  			utils.NodeKeyFileFlag,
   177  			utils.NodeKeyHexFlag,
   178  		},
   179  	},
   180  	{
   181  		Name: "MINER",
   182  		Flags: []cli.Flag{
   183  			utils.MiningEnabledFlag,
   184  			utils.MinerThreadsFlag,
   185  			utils.MinerNotifyFlag,
   186  			utils.MinerNotifyFullFlag,
   187  			utils.MinerGasPriceFlag,
   188  			utils.MinerGasTargetFlag,
   189  			utils.MinerGasLimitFlag,
   190  			utils.MinerEtherbaseFlag,
   191  			utils.MinerExtraDataFlag,
   192  			utils.MinerRecommitIntervalFlag,
   193  			utils.MinerDelayLeftoverFlag,
   194  			utils.MinerNoVerfiyFlag,
   195  		},
   196  	},
   197  	{
   198  		Name: "GAS PRICE ORACLE",
   199  		Flags: []cli.Flag{
   200  			utils.GpoBlocksFlag,
   201  			utils.GpoPercentileFlag,
   202  			utils.GpoMaxGasPriceFlag,
   203  		},
   204  	},
   205  	{
   206  		Name: "VIRTUAL MACHINE",
   207  		Flags: []cli.Flag{
   208  			utils.VMEnableDebugFlag,
   209  			utils.EVMInterpreterFlag,
   210  			utils.EWASMInterpreterFlag,
   211  		},
   212  	},
   213  	{
   214  		Name: "LOGGING AND DEBUGGING",
   215  		Flags: append([]cli.Flag{
   216  			utils.FakePoWFlag,
   217  			utils.NoCompactionFlag,
   218  		}, debug.Flags...),
   219  	},
   220  	{
   221  		Name:  "METRICS AND STATS",
   222  		Flags: metricsFlags,
   223  	},
   224  	{
   225  		Name: "ALIASED (deprecated)",
   226  		Flags: []cli.Flag{
   227  			utils.NoUSBFlag,
   228  			utils.LegacyRPCEnabledFlag,
   229  			utils.LegacyRPCListenAddrFlag,
   230  			utils.LegacyRPCPortFlag,
   231  			utils.LegacyRPCCORSDomainFlag,
   232  			utils.LegacyRPCVirtualHostsFlag,
   233  			utils.LegacyRPCApiFlag,
   234  		},
   235  	},
   236  	{
   237  		Name: "MISC",
   238  		Flags: []cli.Flag{
   239  			utils.SnapshotFlag,
   240  			utils.BloomFilterSizeFlag,
   241  			cli.HelpFlag,
   242  			utils.CatalystFlag,
   243  		},
   244  	},
   245  }
   246  
   247  func init() {
   248  	// Override the default app help template
   249  	cli.AppHelpTemplate = flags.AppHelpTemplate
   250  
   251  	// Override the default app help printer, but only for the global app help
   252  	originalHelpPrinter := cli.HelpPrinter
   253  	cli.HelpPrinter = func(w io.Writer, tmpl string, data interface{}) {
   254  		if tmpl == flags.AppHelpTemplate {
   255  			// Iterate over all the flags and add any uncategorized ones
   256  			categorized := make(map[string]struct{})
   257  			for _, group := range AppHelpFlagGroups {
   258  				for _, flag := range group.Flags {
   259  					categorized[flag.String()] = struct{}{}
   260  				}
   261  			}
   262  			deprecated := make(map[string]struct{})
   263  			for _, flag := range utils.DeprecatedFlags {
   264  				deprecated[flag.String()] = struct{}{}
   265  			}
   266  			// Only add uncategorized flags if they are not deprecated
   267  			var uncategorized []cli.Flag
   268  			for _, flag := range data.(*cli.App).Flags {
   269  				if _, ok := categorized[flag.String()]; !ok {
   270  					if _, ok := deprecated[flag.String()]; !ok {
   271  						uncategorized = append(uncategorized, flag)
   272  					}
   273  				}
   274  			}
   275  			if len(uncategorized) > 0 {
   276  				// Append all ungategorized options to the misc group
   277  				miscs := len(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags)
   278  				AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = append(AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags, uncategorized...)
   279  
   280  				// Make sure they are removed afterwards
   281  				defer func() {
   282  					AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags = AppHelpFlagGroups[len(AppHelpFlagGroups)-1].Flags[:miscs]
   283  				}()
   284  			}
   285  			// Render out custom usage screen
   286  			originalHelpPrinter(w, tmpl, flags.HelpData{App: data, FlagGroups: AppHelpFlagGroups})
   287  		} else if tmpl == flags.CommandHelpTemplate {
   288  			// Iterate over all command specific flags and categorize them
   289  			categorized := make(map[string][]cli.Flag)
   290  			for _, flag := range data.(cli.Command).Flags {
   291  				if _, ok := categorized[flag.String()]; !ok {
   292  					categorized[flags.FlagCategory(flag, AppHelpFlagGroups)] = append(categorized[flags.FlagCategory(flag, AppHelpFlagGroups)], flag)
   293  				}
   294  			}
   295  
   296  			// sort to get a stable ordering
   297  			sorted := make([]flags.FlagGroup, 0, len(categorized))
   298  			for cat, flgs := range categorized {
   299  				sorted = append(sorted, flags.FlagGroup{Name: cat, Flags: flgs})
   300  			}
   301  			sort.Sort(flags.ByCategory(sorted))
   302  
   303  			// add sorted array to data and render with default printer
   304  			originalHelpPrinter(w, tmpl, map[string]interface{}{
   305  				"cmd":              data,
   306  				"categorizedFlags": sorted,
   307  			})
   308  		} else {
   309  			originalHelpPrinter(w, tmpl, data)
   310  		}
   311  	}
   312  }