Skip to content

Commit d570187

Browse files
committed
make suggested changes
1 parent dc4b07b commit d570187

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

cmd/geth/chaincmd.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ It expects the genesis file as argument.`,
6161
Name: "dumpgenesis",
6262
Usage: "Dumps genesis block JSON configuration to stdout",
6363
ArgsUsage: "",
64-
Flags: utils.NetworkFlags,
64+
Flags: append([]cli.Flag{utils.DataDirFlag}, utils.NetworkFlags...),
6565
Category: "BLOCKCHAIN COMMANDS",
6666
Description: `
67-
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.`,
67+
The dumpgenesis command prints the genesis configuration of the network preset
68+
if one is set. Otherwise it prints the genesis from the datadir.`,
6869
}
6970
importCommand = cli.Command{
7071
Action: utils.MigrateFlags(importChain),
@@ -208,7 +209,7 @@ func initGenesis(ctx *cli.Context) error {
208209

209210
func dumpGenesis(ctx *cli.Context) error {
210211
// if there is a testnet preset enabled, dump that
211-
if utils.IsTestnetPreset(ctx) {
212+
if utils.IsNetworkPreset(ctx) {
212213
genesis := utils.MakeGenesis(ctx)
213214
if err := json.NewEncoder(os.Stdout).Encode(genesis); err != nil {
214215
utils.Fatalf("could not encode genesis: %s", err)
@@ -239,10 +240,7 @@ func dumpGenesis(ctx *cli.Context) error {
239240
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
240241
utils.Fatalf("no existing datadir at %s", stack.Config().DataDir)
241242
}
242-
// no datadir exists or is specified, dump mainnet
243-
if err := json.NewEncoder(os.Stdout).Encode(core.DefaultGenesisBlock()); err != nil {
244-
utils.Fatalf("could not encode genesis: %s", err)
245-
}
243+
utils.Fatalf("no network preset provided. no exisiting genesis in the default datadir")
246244
return nil
247245
}
248246

cmd/utils/flags.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,12 +1987,15 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
19871987
return chainDb
19881988
}
19891989

1990-
func IsTestnetPreset(ctx *cli.Context) bool {
1990+
func IsNetworkPreset(ctx *cli.Context) bool {
19911991
for _, flag := range TestnetFlags {
19921992
if ctx.GlobalBool(flag.GetName()) {
19931993
return true
19941994
}
19951995
}
1996+
if ctx.GlobalBool(MainnetFlag.Name) {
1997+
return true
1998+
}
19961999
return false
19972000
}
19982001

0 commit comments

Comments
 (0)