From 71ec0938b5691d34a2d5940c67db62c7d11aa086 Mon Sep 17 00:00:00 2001 From: Alex Sharov <AskAlexSharov@gmail.com> Date: Fri, 10 Sep 2021 10:06:23 +0700 Subject: [PATCH] fix wrong order of constructor (#2657) --- eth/backend.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index fd22d8973b..cd2f40d86e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -356,23 +356,6 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere } config.BodyDownloadTimeoutSeconds = 30 - emptyBadHash := config.BadBlockHash == common.Hash{} - if !emptyBadHash { - var badBlockHeader *types.Header - if err = chainKv.View(context.Background(), func(tx kv.Tx) error { - header, hErr := rawdb.ReadHeaderByHash(tx, config.BadBlockHash) - badBlockHeader = header - return hErr - }); err != nil { - return nil, err - } - - if badBlockHeader != nil { - unwindPoint := badBlockHeader.Number.Uint64() - 1 - backend.stagedSync.UnwindTo(unwindPoint, config.BadBlockHash) - } - } - var txPoolRPC txpool_proto.TxpoolServer var miningRPC txpool_proto.MiningServer if config.TxPool.V2 { @@ -529,6 +512,23 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere return nil, err } + emptyBadHash := config.BadBlockHash == common.Hash{} + if !emptyBadHash { + var badBlockHeader *types.Header + if err = chainKv.View(context.Background(), func(tx kv.Tx) error { + header, hErr := rawdb.ReadHeaderByHash(tx, config.BadBlockHash) + badBlockHeader = header + return hErr + }); err != nil { + return nil, err + } + + if badBlockHeader != nil { + unwindPoint := badBlockHeader.Number.Uint64() - 1 + backend.stagedSync.UnwindTo(unwindPoint, config.BadBlockHash) + } + } + //eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil} gpoParams := config.GPO if gpoParams.Default == nil { -- GitLab