From 6eed590f120d0cf9fe674a72d8795518f3cd886e Mon Sep 17 00:00:00 2001 From: weiihann Date: Thu, 29 Feb 2024 14:54:35 +0800 Subject: [PATCH] cmd/geth: fix importBlock --- cmd/geth/chaincmd.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 70f4bee426..d9307052d3 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -41,6 +41,7 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/internal/era" "github.com/ethereum/go-ethereum/internal/flags" @@ -500,10 +501,16 @@ func importChain(ctx *cli.Context) error { // Start system runtime metrics collection go metrics.CollectProcessMetrics(3 * time.Second) - stack, _ := makeConfigNode(ctx) + stack, cfg := makeConfigNode(ctx) defer stack.Close() - chain, db := utils.MakeChain(ctx, stack, false) + backend, err := eth.New(stack, &cfg.Eth) + if err != nil { + return err + } + + chain := backend.BlockChain() + db := backend.ChainDb() defer db.Close() // Start periodically gathering memory profiles