good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 711ed74e authored by meowsbits's avatar meowsbits Committed by GitHub
Browse files

cmd/geth: add 'dumpgenesis' command (#20191)

Adds the 'geth dumpgenesis' command, which writes the configured
genesis in JSON format to stdout. This provides a way to generate the
data (structure and content) that can then be used with the 'geth init'
command.
parent 058a4ac5
No related branches found
No related tags found
No related merge requests found
...@@ -56,6 +56,18 @@ This is a destructive action and changes the network in which you will be ...@@ -56,6 +56,18 @@ This is a destructive action and changes the network in which you will be
participating. participating.
It expects the genesis file as argument.`, It expects the genesis file as argument.`,
}
dumpGenesisCommand = cli.Command{
Action: utils.MigrateFlags(dumpGenesis),
Name: "dumpgenesis",
Usage: "Dumps genesis block JSON configuration to stdout",
ArgsUsage: "",
Flags: []cli.Flag{
utils.DataDirFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
The dumpgenesis command dumps the genesis block configuration in JSON format to stdout.`,
} }
importCommand = cli.Command{ importCommand = cli.Command{
Action: utils.MigrateFlags(importChain), Action: utils.MigrateFlags(importChain),
...@@ -227,6 +239,17 @@ func initGenesis(ctx *cli.Context) error { ...@@ -227,6 +239,17 @@ func initGenesis(ctx *cli.Context) error {
return nil return nil
} }
func dumpGenesis(ctx *cli.Context) error {
genesis := utils.MakeGenesis(ctx)
if genesis == nil {
genesis = core.DefaultGenesisBlock()
}
if err := json.NewEncoder(os.Stdout).Encode(genesis); err != nil {
utils.Fatalf("could not encode genesis")
}
return nil
}
func importChain(ctx *cli.Context) error { func importChain(ctx *cli.Context) error {
if len(ctx.Args()) < 1 { if len(ctx.Args()) < 1 {
utils.Fatalf("This command requires an argument.") utils.Fatalf("This command requires an argument.")
......
...@@ -205,6 +205,7 @@ func init() { ...@@ -205,6 +205,7 @@ func init() {
copydbCommand, copydbCommand,
removedbCommand, removedbCommand,
dumpCommand, dumpCommand,
dumpGenesisCommand,
inspectCommand, inspectCommand,
// See accountcmd.go: // See accountcmd.go:
accountCommand, accountCommand,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment