@@ -444,7 +444,7 @@ func importHistory(ctx *cli.Context) error {
444444 return fmt .Errorf ("no era1 files found in %s" , dir )
445445 }
446446 if len (networks ) > 1 {
447- return fmt . Errorf ("multiple networks found, use a network flag to specify desired network" )
447+ return errors . New ("multiple networks found, use a network flag to specify desired network" )
448448 }
449449 network = networks [0 ]
450450 }
@@ -514,13 +514,10 @@ func importPreimages(ctx *cli.Context) error {
514514 return nil
515515}
516516
517- func parseDumpConfig (ctx * cli.Context , stack * node.Node ) (* state.DumpConfig , ethdb.Database , common.Hash , error ) {
518- db := utils .MakeChainDatabase (ctx , stack , true )
519- defer db .Close ()
520-
517+ func parseDumpConfig (ctx * cli.Context , stack * node.Node , db ethdb.Database ) (* state.DumpConfig , common.Hash , error ) {
521518 var header * types.Header
522519 if ctx .NArg () > 1 {
523- return nil , nil , common.Hash {}, fmt .Errorf ("expected 1 argument (number or hash), got %d" , ctx .NArg ())
520+ return nil , common.Hash {}, fmt .Errorf ("expected 1 argument (number or hash), got %d" , ctx .NArg ())
524521 }
525522 if ctx .NArg () == 1 {
526523 arg := ctx .Args ().First ()
@@ -529,25 +526,25 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
529526 if number := rawdb .ReadHeaderNumber (db , hash ); number != nil {
530527 header = rawdb .ReadHeader (db , hash , * number )
531528 } else {
532- return nil , nil , common.Hash {}, fmt .Errorf ("block %x not found" , hash )
529+ return nil , common.Hash {}, fmt .Errorf ("block %x not found" , hash )
533530 }
534531 } else {
535532 number , err := strconv .ParseUint (arg , 10 , 64 )
536533 if err != nil {
537- return nil , nil , common.Hash {}, err
534+ return nil , common.Hash {}, err
538535 }
539536 if hash := rawdb .ReadCanonicalHash (db , number ); hash != (common.Hash {}) {
540537 header = rawdb .ReadHeader (db , hash , number )
541538 } else {
542- return nil , nil , common.Hash {}, fmt .Errorf ("header for block %d not found" , number )
539+ return nil , common.Hash {}, fmt .Errorf ("header for block %d not found" , number )
543540 }
544541 }
545542 } else {
546543 // Use latest
547544 header = rawdb .ReadHeadHeader (db )
548545 }
549546 if header == nil {
550- return nil , nil , common.Hash {}, errors .New ("no head block found" )
547+ return nil , common.Hash {}, errors .New ("no head block found" )
551548 }
552549 startArg := common .FromHex (ctx .String (utils .StartKeyFlag .Name ))
553550 var start common.Hash
@@ -559,7 +556,7 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
559556 start = crypto .Keccak256Hash (startArg )
560557 log .Info ("Converting start-address to hash" , "address" , common .BytesToAddress (startArg ), "hash" , start .Hex ())
561558 default :
562- return nil , nil , common.Hash {}, fmt .Errorf ("invalid start argument: %x. 20 or 32 hex-encoded bytes required" , startArg )
559+ return nil , common.Hash {}, fmt .Errorf ("invalid start argument: %x. 20 or 32 hex-encoded bytes required" , startArg )
563560 }
564561 var conf = & state.DumpConfig {
565562 SkipCode : ctx .Bool (utils .ExcludeCodeFlag .Name ),
@@ -571,14 +568,17 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
571568 log .Info ("State dump configured" , "block" , header .Number , "hash" , header .Hash ().Hex (),
572569 "skipcode" , conf .SkipCode , "skipstorage" , conf .SkipStorage ,
573570 "start" , hexutil .Encode (conf .Start ), "limit" , conf .Max )
574- return conf , db , header .Root , nil
571+ return conf , header .Root , nil
575572}
576573
577574func dump (ctx * cli.Context ) error {
578575 stack , _ := makeConfigNode (ctx )
579576 defer stack .Close ()
580577
581- conf , db , root , err := parseDumpConfig (ctx , stack )
578+ db := utils .MakeChainDatabase (ctx , stack , true )
579+ defer db .Close ()
580+
581+ conf , root , err := parseDumpConfig (ctx , stack , db )
582582 if err != nil {
583583 return err
584584 }
0 commit comments