Skip to content

Commit 5705985

Browse files
committed
make suggested changes
1 parent cd34a0f commit 5705985

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

cmd/geth/chaincmd.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ It expects the genesis file as argument.`,
6060
Name: "dumpgenesis",
6161
Usage: "Dumps genesis block JSON configuration to stdout",
6262
ArgsUsage: "",
63-
Flags: utils.NetworkFlags,
63+
Flags: append([]cli.Flag{utils.DataDirFlag}, utils.NetworkFlags...),
64+
Category: "BLOCKCHAIN COMMANDS",
6465
Description: `
65-
The dumpgenesis command prints a genesis block as JSON. What it outputs is determined in order of preference: testnet preset if it is set, preexisting datadir, mainnet.`,
66+
The dumpgenesis command prints the genesis configuration of the network preset
67+
if one is set. Otherwise it prints the genesis from the datadir.`,
6668
}
6769
importCommand = &cli.Command{
6870
Action: importChain,
@@ -203,7 +205,7 @@ func initGenesis(ctx *cli.Context) error {
203205

204206
func dumpGenesis(ctx *cli.Context) error {
205207
// if there is a testnet preset enabled, dump that
206-
if utils.IsTestnetPreset(ctx) {
208+
if utils.IsNetworkPreset(ctx) {
207209
genesis := utils.MakeGenesis(ctx)
208210
if err := json.NewEncoder(os.Stdout).Encode(genesis); err != nil {
209211
utils.Fatalf("could not encode genesis: %s", err)
@@ -231,13 +233,10 @@ func dumpGenesis(ctx *cli.Context) error {
231233
}
232234
return nil
233235
}
234-
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
236+
if ctx.IsSet(utils.DataDirFlag.Name) {
235237
utils.Fatalf("no existing datadir at %s", stack.Config().DataDir)
236238
}
237-
// no datadir exists or is specified, dump mainnet
238-
if err := json.NewEncoder(os.Stdout).Encode(core.DefaultGenesisBlock()); err != nil {
239-
utils.Fatalf("could not encode genesis: %s", err)
240-
}
239+
utils.Fatalf("no network preset provided. no exisiting genesis in the default datadir")
241240
return nil
242241
}
243242

cmd/utils/flags.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,12 +2134,15 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
21342134
return chainDb
21352135
}
21362136

2137-
func IsTestnetPreset(ctx *cli.Context) bool {
2137+
func IsNetworkPreset(ctx *cli.Context) bool {
21382138
for _, flag := range TestnetFlags {
2139-
if ctx.GlobalBool(flag.GetName()) {
2139+
if ctx.Bool(flag.String()) {
21402140
return true
21412141
}
21422142
}
2143+
if ctx.Bool(MainnetFlag.Name) {
2144+
return true
2145+
}
21432146
return false
21442147
}
21452148

0 commit comments

Comments
 (0)