Skip to content

Commit 344d6f9

Browse files
authored
cmd: group network and db path flags together (ethereum#24698)
This PR groups all built-in network flags together and list them in the command as a whole. And all database path flags(datadir, ancient) are also grouped, since usually these two are used together.
1 parent 5157d45 commit 344d6f9

File tree

9 files changed

+113
-219
lines changed

9 files changed

+113
-219
lines changed

cmd/devp2p/internal/ethtest/snap.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,8 @@ func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
372372
{
373373
root: s.chain.RootAt(999),
374374
paths: []snap.TrieNodePathSet{
375-
snap.TrieNodePathSet{}, // zero-length pathset should 'abort' and kick us off
376-
snap.TrieNodePathSet{[]byte{0}},
375+
{}, // zero-length pathset should 'abort' and kick us off
376+
{[]byte{0}},
377377
},
378378
nBytes: 5000,
379379
expHashes: []common.Hash{},
@@ -382,8 +382,8 @@ func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
382382
{
383383
root: s.chain.RootAt(999),
384384
paths: []snap.TrieNodePathSet{
385-
snap.TrieNodePathSet{[]byte{0}},
386-
snap.TrieNodePathSet{[]byte{1}, []byte{0}},
385+
{[]byte{0}},
386+
{[]byte{1}, []byte{0}},
387387
},
388388
nBytes: 5000,
389389
//0x6b3724a41b8c38b46d4d02fba2bb2074c47a507eb16a9a4b978f91d32e406faf
@@ -392,7 +392,7 @@ func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
392392
{ // nonsensically long path
393393
root: s.chain.RootAt(999),
394394
paths: []snap.TrieNodePathSet{
395-
snap.TrieNodePathSet{[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8,
395+
{[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8,
396396
0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8}},
397397
},
398398
nBytes: 5000,
@@ -401,8 +401,8 @@ func (s *Suite) TestSnapTrieNodes(t *utesting.T) {
401401
{
402402
root: s.chain.RootAt(0),
403403
paths: []snap.TrieNodePathSet{
404-
snap.TrieNodePathSet{[]byte{0}},
405-
snap.TrieNodePathSet{[]byte{1}, []byte{0}},
404+
{[]byte{0}},
405+
{[]byte{1}, []byte{0}},
406406
},
407407
nBytes: 5000,
408408
expHashes: []common.Hash{},

cmd/geth/chaincmd.go

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ var (
4747
Name: "init",
4848
Usage: "Bootstrap and initialize a new genesis block",
4949
ArgsUsage: "<genesisPath>",
50-
Flags: []cli.Flag{
51-
utils.DataDirFlag,
52-
},
53-
Category: "BLOCKCHAIN COMMANDS",
50+
Flags: utils.DatabasePathFlags,
51+
Category: "BLOCKCHAIN COMMANDS",
5452
Description: `
5553
The init command initializes a new genesis block and definition for the network.
5654
This is a destructive action and changes the network in which you will be
@@ -63,14 +61,8 @@ It expects the genesis file as argument.`,
6361
Name: "dumpgenesis",
6462
Usage: "Dumps genesis block JSON configuration to stdout",
6563
ArgsUsage: "",
66-
Flags: []cli.Flag{
67-
utils.MainnetFlag,
68-
utils.RopstenFlag,
69-
utils.SepoliaFlag,
70-
utils.RinkebyFlag,
71-
utils.GoerliFlag,
72-
},
73-
Category: "BLOCKCHAIN COMMANDS",
64+
Flags: utils.NetworkFlags,
65+
Category: "BLOCKCHAIN COMMANDS",
7466
Description: `
7567
The dumpgenesis command dumps the genesis block configuration in JSON format to stdout.`,
7668
}
@@ -79,8 +71,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
7971
Name: "import",
8072
Usage: "Import a blockchain file",
8173
ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
82-
Flags: []cli.Flag{
83-
utils.DataDirFlag,
74+
Flags: append([]cli.Flag{
8475
utils.CacheFlag,
8576
utils.SyncModeFlag,
8677
utils.GCModeFlag,
@@ -102,7 +93,7 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
10293
utils.MetricsInfluxDBBucketFlag,
10394
utils.MetricsInfluxDBOrganizationFlag,
10495
utils.TxLookupLimitFlag,
105-
},
96+
}, utils.DatabasePathFlags...),
10697
Category: "BLOCKCHAIN COMMANDS",
10798
Description: `
10899
The import command imports blocks from an RLP-encoded form. The form can be one file
@@ -116,11 +107,10 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
116107
Name: "export",
117108
Usage: "Export blockchain into file",
118109
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
119-
Flags: []cli.Flag{
120-
utils.DataDirFlag,
110+
Flags: append([]cli.Flag{
121111
utils.CacheFlag,
122112
utils.SyncModeFlag,
123-
},
113+
}, utils.DatabasePathFlags...),
124114
Category: "BLOCKCHAIN COMMANDS",
125115
Description: `
126116
Requires a first argument of the file to write to.
@@ -134,11 +124,10 @@ be gzipped.`,
134124
Name: "import-preimages",
135125
Usage: "Import the preimage database from an RLP stream",
136126
ArgsUsage: "<datafile>",
137-
Flags: []cli.Flag{
138-
utils.DataDirFlag,
127+
Flags: append([]cli.Flag{
139128
utils.CacheFlag,
140129
utils.SyncModeFlag,
141-
},
130+
}, utils.DatabasePathFlags...),
142131
Category: "BLOCKCHAIN COMMANDS",
143132
Description: `
144133
The import-preimages command imports hash preimages from an RLP encoded stream.
@@ -150,11 +139,10 @@ It's deprecated, please use "geth db import" instead.
150139
Name: "export-preimages",
151140
Usage: "Export the preimage database into an RLP stream",
152141
ArgsUsage: "<dumpfile>",
153-
Flags: []cli.Flag{
154-
utils.DataDirFlag,
142+
Flags: append([]cli.Flag{
155143
utils.CacheFlag,
156144
utils.SyncModeFlag,
157-
},
145+
}, utils.DatabasePathFlags...),
158146
Category: "BLOCKCHAIN COMMANDS",
159147
Description: `
160148
The export-preimages command exports hash preimages to an RLP encoded stream.
@@ -166,16 +154,15 @@ It's deprecated, please use "geth db export" instead.
166154
Name: "dump",
167155
Usage: "Dump a specific block from storage",
168156
ArgsUsage: "[? <blockHash> | <blockNum>]",
169-
Flags: []cli.Flag{
170-
utils.DataDirFlag,
157+
Flags: append([]cli.Flag{
171158
utils.CacheFlag,
172159
utils.IterativeOutputFlag,
173160
utils.ExcludeCodeFlag,
174161
utils.ExcludeStorageFlag,
175162
utils.IncludeIncompletesFlag,
176163
utils.StartKeyFlag,
177164
utils.DumpLimitFlag,
178-
},
165+
}, utils.DatabasePathFlags...),
179166
Category: "BLOCKCHAIN COMMANDS",
180167
Description: `
181168
This command dumps out the state for a given block (or latest, if none provided).

cmd/geth/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var (
4848
Name: "dumpconfig",
4949
Usage: "Show configuration values",
5050
ArgsUsage: "",
51-
Flags: append(nodeFlags, rpcFlags...),
51+
Flags: utils.GroupFlags(nodeFlags, rpcFlags),
5252
Category: "MISCELLANEOUS COMMANDS",
5353
Description: `The dumpconfig command shows configuration values.`,
5454
}

cmd/geth/consolecmd.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var (
3636
Action: utils.MigrateFlags(localConsole),
3737
Name: "console",
3838
Usage: "Start an interactive JavaScript environment",
39-
Flags: append(append(nodeFlags, rpcFlags...), consoleFlags...),
39+
Flags: utils.GroupFlags(nodeFlags, rpcFlags, consoleFlags),
4040
Category: "CONSOLE COMMANDS",
4141
Description: `
4242
The Geth console is an interactive shell for the JavaScript runtime environment
@@ -49,7 +49,7 @@ See https://geth.ethereum.org/docs/interface/javascript-console.`,
4949
Name: "attach",
5050
Usage: "Start an interactive JavaScript environment (connect to node)",
5151
ArgsUsage: "[endpoint]",
52-
Flags: append(consoleFlags, utils.DataDirFlag),
52+
Flags: utils.GroupFlags([]cli.Flag{utils.DataDirFlag}, consoleFlags),
5353
Category: "CONSOLE COMMANDS",
5454
Description: `
5555
The Geth console is an interactive shell for the JavaScript runtime environment
@@ -63,7 +63,7 @@ This command allows to open a console on a running geth node.`,
6363
Name: "js",
6464
Usage: "Execute the specified JavaScript files",
6565
ArgsUsage: "<jsfile> [jsfile...]",
66-
Flags: append(nodeFlags, consoleFlags...),
66+
Flags: utils.GroupFlags(nodeFlags, consoleFlags),
6767
Category: "CONSOLE COMMANDS",
6868
Description: `
6969
The JavaScript VM exposes a node admin interface as well as the Ðapp
@@ -141,6 +141,8 @@ func remoteConsole(ctx *cli.Context) error {
141141
path = filepath.Join(path, "goerli")
142142
} else if ctx.GlobalBool(utils.SepoliaFlag.Name) {
143143
path = filepath.Join(path, "sepolia")
144+
} else if ctx.GlobalBool(utils.KilnFlag.Name) {
145+
path = filepath.Join(path, "kiln")
144146
}
145147
}
146148
endpoint = fmt.Sprintf("%s/geth.ipc", path)

0 commit comments

Comments
 (0)