cmd/geth: make dumpgenesis load genesis datadir if it exists (#25135)

`geth dumpgenesis` currently does not respect the content of the data directory. Instead, it outputs the genesis block created by command-line flags. This PR fixes it to read the genesis from the database, if the database already exists.


Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
jwasinger
2022-09-26 13:55:18 +02:00
committed by GitHub
co-authored by Martin Holst Swende
parent c55c56cf0a
commit 7227c9ef07
3 changed files with 80 additions and 11 deletions
+11 -3
View File
@@ -988,9 +988,7 @@ var (
KilnFlag,
}
// NetworkFlags is the flag group of all built-in supported networks.
NetworkFlags = append([]cli.Flag{
MainnetFlag,
}, TestnetFlags...)
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
// DatabasePathFlags is the flag group of all database path flags.
DatabasePathFlags = []cli.Flag{
@@ -2140,6 +2138,16 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node, readonly bool) ethdb.
return chainDb
}
func IsNetworkPreset(ctx *cli.Context) bool {
for _, flag := range NetworkFlags {
bFlag, _ := flag.(*cli.BoolFlag)
if ctx.IsSet(bFlag.Name) {
return true
}
}
return false
}
func MakeGenesis(ctx *cli.Context) *core.Genesis {
var genesis *core.Genesis
switch {