Skip to content

Commit c674980

Browse files
committed
cmd: group network and db path flags together
1 parent 9f7bcb9 commit c674980

File tree

8 files changed

+104
-206
lines changed

8 files changed

+104
-206
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/consolecmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

cmd/geth/dbcmd.go

Lines changed: 26 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ var (
4949
Name: "removedb",
5050
Usage: "Remove blockchain and state databases",
5151
ArgsUsage: "",
52-
Flags: []cli.Flag{
53-
utils.DataDirFlag,
54-
},
55-
Category: "DATABASE COMMANDS",
52+
Flags: utils.DatabasePathFlags,
53+
Category: "DATABASE COMMANDS",
5654
Description: `
5755
Remove blockchain and state databases`,
5856
}
@@ -80,48 +78,29 @@ Remove blockchain and state databases`,
8078
Action: utils.MigrateFlags(inspect),
8179
Name: "inspect",
8280
ArgsUsage: "<prefix> <start>",
83-
Flags: []cli.Flag{
84-
utils.DataDirFlag,
85-
utils.AncientFlag,
81+
Flags: append([]cli.Flag{
8682
utils.SyncModeFlag,
87-
utils.MainnetFlag,
88-
utils.RopstenFlag,
89-
utils.SepoliaFlag,
90-
utils.RinkebyFlag,
91-
utils.GoerliFlag,
92-
},
83+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
9384
Usage: "Inspect the storage size for each type of data in the database",
9485
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
9586
}
9687
dbStatCmd = cli.Command{
9788
Action: utils.MigrateFlags(dbStats),
9889
Name: "stats",
9990
Usage: "Print leveldb statistics",
100-
Flags: []cli.Flag{
101-
utils.DataDirFlag,
91+
Flags: append([]cli.Flag{
10292
utils.SyncModeFlag,
103-
utils.MainnetFlag,
104-
utils.RopstenFlag,
105-
utils.SepoliaFlag,
106-
utils.RinkebyFlag,
107-
utils.GoerliFlag,
108-
},
93+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
10994
}
11095
dbCompactCmd = cli.Command{
11196
Action: utils.MigrateFlags(dbCompact),
11297
Name: "compact",
11398
Usage: "Compact leveldb database. WARNING: May take a very long time",
114-
Flags: []cli.Flag{
115-
utils.DataDirFlag,
99+
Flags: append([]cli.Flag{
116100
utils.SyncModeFlag,
117-
utils.MainnetFlag,
118-
utils.RopstenFlag,
119-
utils.SepoliaFlag,
120-
utils.RinkebyFlag,
121-
utils.GoerliFlag,
122101
utils.CacheFlag,
123102
utils.CacheDatabaseFlag,
124-
},
103+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
125104
Description: `This command performs a database compaction.
126105
WARNING: This operation may take a very long time to finish, and may cause database
127106
corruption if it is aborted during execution'!`,
@@ -131,31 +110,19 @@ corruption if it is aborted during execution'!`,
131110
Name: "get",
132111
Usage: "Show the value of a database key",
133112
ArgsUsage: "<hex-encoded key>",
134-
Flags: []cli.Flag{
135-
utils.DataDirFlag,
113+
Flags: append([]cli.Flag{
136114
utils.SyncModeFlag,
137-
utils.MainnetFlag,
138-
utils.RopstenFlag,
139-
utils.SepoliaFlag,
140-
utils.RinkebyFlag,
141-
utils.GoerliFlag,
142-
},
115+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
143116
Description: "This command looks up the specified database key from the database.",
144117
}
145118
dbDeleteCmd = cli.Command{
146119
Action: utils.MigrateFlags(dbDelete),
147120
Name: "delete",
148121
Usage: "Delete a database key (WARNING: may corrupt your database)",
149122
ArgsUsage: "<hex-encoded key>",
150-
Flags: []cli.Flag{
151-
utils.DataDirFlag,
123+
Flags: append([]cli.Flag{
152124
utils.SyncModeFlag,
153-
utils.MainnetFlag,
154-
utils.RopstenFlag,
155-
utils.SepoliaFlag,
156-
utils.RinkebyFlag,
157-
utils.GoerliFlag,
158-
},
125+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
159126
Description: `This command deletes the specified database key from the database.
160127
WARNING: This is a low-level operation which may cause database corruption!`,
161128
}
@@ -164,15 +131,9 @@ WARNING: This is a low-level operation which may cause database corruption!`,
164131
Name: "put",
165132
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
166133
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
167-
Flags: []cli.Flag{
168-
utils.DataDirFlag,
134+
Flags: append([]cli.Flag{
169135
utils.SyncModeFlag,
170-
utils.MainnetFlag,
171-
utils.RopstenFlag,
172-
utils.SepoliaFlag,
173-
utils.RinkebyFlag,
174-
utils.GoerliFlag,
175-
},
136+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
176137
Description: `This command sets a given database key to the given value.
177138
WARNING: This is a low-level operation which may cause database corruption!`,
178139
}
@@ -181,92 +142,58 @@ WARNING: This is a low-level operation which may cause database corruption!`,
181142
Name: "dumptrie",
182143
Usage: "Show the storage key/values of a given storage trie",
183144
ArgsUsage: "<hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>",
184-
Flags: []cli.Flag{
185-
utils.DataDirFlag,
145+
Flags: append([]cli.Flag{
186146
utils.SyncModeFlag,
187-
utils.MainnetFlag,
188-
utils.RopstenFlag,
189-
utils.SepoliaFlag,
190-
utils.RinkebyFlag,
191-
utils.GoerliFlag,
192-
},
147+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
193148
Description: "This command looks up the specified database key from the database.",
194149
}
195150
dbDumpFreezerIndex = cli.Command{
196151
Action: utils.MigrateFlags(freezerInspect),
197152
Name: "freezer-index",
198153
Usage: "Dump out the index of a given freezer type",
199154
ArgsUsage: "<type> <start (int)> <end (int)>",
200-
Flags: []cli.Flag{
201-
utils.DataDirFlag,
155+
Flags: append([]cli.Flag{
202156
utils.SyncModeFlag,
203-
utils.MainnetFlag,
204-
utils.RopstenFlag,
205-
utils.SepoliaFlag,
206-
utils.RinkebyFlag,
207-
utils.GoerliFlag,
208-
},
157+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
209158
Description: "This command displays information about the freezer index.",
210159
}
211160
dbImportCmd = cli.Command{
212161
Action: utils.MigrateFlags(importLDBdata),
213162
Name: "import",
214163
Usage: "Imports leveldb-data from an exported RLP dump.",
215164
ArgsUsage: "<dumpfile> <start (optional)",
216-
Flags: []cli.Flag{
217-
utils.DataDirFlag,
165+
Flags: append([]cli.Flag{
218166
utils.SyncModeFlag,
219-
utils.MainnetFlag,
220-
utils.RopstenFlag,
221-
utils.RinkebyFlag,
222-
utils.GoerliFlag,
223-
},
167+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
224168
Description: "The import command imports the specific chain data from an RLP encoded stream.",
225169
}
226170
dbExportCmd = cli.Command{
227171
Action: utils.MigrateFlags(exportChaindata),
228172
Name: "export",
229173
Usage: "Exports the chain data into an RLP dump. If the <dumpfile> has .gz suffix, gzip compression will be used.",
230174
ArgsUsage: "<type> <dumpfile>",
231-
Flags: []cli.Flag{
232-
utils.DataDirFlag,
175+
Flags: append([]cli.Flag{
233176
utils.SyncModeFlag,
234-
utils.MainnetFlag,
235-
utils.RopstenFlag,
236-
utils.RinkebyFlag,
237-
utils.GoerliFlag,
238-
},
177+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
239178
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.",
240179
}
241180
dbMetadataCmd = cli.Command{
242181
Action: utils.MigrateFlags(showMetaData),
243182
Name: "metadata",
244183
Usage: "Shows metadata about the chain status.",
245-
Flags: []cli.Flag{
246-
utils.DataDirFlag,
184+
Flags: append([]cli.Flag{
247185
utils.SyncModeFlag,
248-
utils.MainnetFlag,
249-
utils.RopstenFlag,
250-
utils.SepoliaFlag,
251-
utils.RinkebyFlag,
252-
utils.GoerliFlag,
253-
},
186+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
254187
Description: "Shows metadata about the chain status.",
255188
}
256189
dbMigrateFreezerCmd = cli.Command{
257190
Action: utils.MigrateFlags(freezerMigrate),
258191
Name: "freezer-migrate",
259192
Usage: "Migrate legacy parts of the freezer. (WARNING: may take a long time)",
260193
ArgsUsage: "",
261-
Flags: []cli.Flag{
262-
utils.DataDirFlag,
194+
Flags: append([]cli.Flag{
263195
utils.SyncModeFlag,
264-
utils.MainnetFlag,
265-
utils.RopstenFlag,
266-
utils.SepoliaFlag,
267-
utils.RinkebyFlag,
268-
utils.GoerliFlag,
269-
},
196+
}, utils.GroupFlags(utils.NetworkFlags, utils.DatabasePathFlags)...),
270197
Description: `The freezer-migrate command checks your database for receipts in a legacy format and updates those.
271198
WARNING: please back-up the receipt files in your ancients before running this command.`,
272199
}

0 commit comments

Comments
 (0)