Skip to content

Commit d21303f

Browse files
authored
cmd/geth: fixes db unavailability for chain commands (#21415)
* chaincmd should make config nodes instead of full nodes * add documentation for using makeConfigNode instead of makeFullNode; * add documentation to functions * code style
1 parent 4fde0ca commit d21303f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

cmd/geth/chaincmd.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ func initGenesis(ctx *cli.Context) error {
239239
if err := json.NewDecoder(file).Decode(genesis); err != nil {
240240
utils.Fatalf("invalid genesis file: %v", err)
241241
}
242-
243-
// Open an initialise both full and light databases
242+
// Open and initialise both full and light databases
244243
stack, _ := makeConfigNode(ctx)
245244
defer stack.Close()
246245

@@ -409,7 +408,8 @@ func importPreimages(ctx *cli.Context) error {
409408
if len(ctx.Args()) < 1 {
410409
utils.Fatalf("This command requires an argument.")
411410
}
412-
stack, _ := makeFullNode(ctx)
411+
412+
stack, _ := makeConfigNode(ctx)
413413
defer stack.Close()
414414

415415
db := utils.MakeChainDatabase(ctx, stack)
@@ -427,7 +427,8 @@ func exportPreimages(ctx *cli.Context) error {
427427
if len(ctx.Args()) < 1 {
428428
utils.Fatalf("This command requires an argument.")
429429
}
430-
stack, _ := makeFullNode(ctx)
430+
431+
stack, _ := makeConfigNode(ctx)
431432
defer stack.Close()
432433

433434
db := utils.MakeChainDatabase(ctx, stack)
@@ -449,7 +450,7 @@ func copyDb(ctx *cli.Context) error {
449450
utils.Fatalf("Source ancient chain directory path argument missing")
450451
}
451452
// Initialize a new chain for the running node to sync into
452-
stack, _ := makeFullNode(ctx)
453+
stack, _ := makeConfigNode(ctx)
453454
defer stack.Close()
454455

455456
chain, chainDb := utils.MakeChain(ctx, stack, false)
@@ -557,7 +558,7 @@ func confirmAndRemoveDB(database string, kind string) {
557558
}
558559

559560
func dump(ctx *cli.Context) error {
560-
stack, _ := makeFullNode(ctx)
561+
stack, _ := makeConfigNode(ctx)
561562
defer stack.Close()
562563

563564
chain, chainDb := utils.MakeChain(ctx, stack, true)

cmd/geth/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func defaultNodeConfig() node.Config {
105105
return cfg
106106
}
107107

108+
// makeConfigNode loads geth configuration and creates a blank node instance.
108109
func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
109110
// Load defaults.
110111
cfg := gethConfig{
@@ -145,6 +146,7 @@ func enableWhisper(ctx *cli.Context) bool {
145146
return false
146147
}
147148

149+
// makeFullNode loads geth configuration and creates the Ethereum backend.
148150
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
149151
stack, cfg := makeConfigNode(ctx)
150152

0 commit comments

Comments
 (0)