mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
fix: create engine before blochain
This commit is contained in:
parent
2f79768ad0
commit
7319922ad5
1 changed files with 25 additions and 12 deletions
|
|
@ -140,6 +140,19 @@ func New(stack *node.Node, config *Config) (*Ethereum, error) {
|
|||
p2pServer: stack.Server(),
|
||||
}
|
||||
|
||||
// START: Bor changes
|
||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), eth, nil}
|
||||
gpoParams := config.GPO
|
||||
if gpoParams.Default == nil {
|
||||
gpoParams.Default = config.Miner.GasPrice
|
||||
}
|
||||
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
|
||||
|
||||
// create eth api and set engine
|
||||
ethAPI := ethapi.NewPublicBlockChainAPI(eth.APIBackend)
|
||||
eth.engine = CreateConsensusEngine(stack, chainConfig, config, chainDb, ethAPI)
|
||||
// END: Bor changes
|
||||
|
||||
bcVersion := rawdb.ReadDatabaseVersion(chainDb)
|
||||
var dbVer = "<nil>"
|
||||
if bcVersion != nil {
|
||||
|
|
@ -176,6 +189,8 @@ func New(stack *node.Node, config *Config) (*Ethereum, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
eth.engine.VerifyHeader(eth.blockchain, eth.blockchain.CurrentHeader(), true) // TODO think on it
|
||||
|
||||
// Rewind the chain in case of an incompatible config upgrade.
|
||||
if compat, ok := genesisErr.(*params.ConfigCompatError); ok {
|
||||
log.Warn("Rewinding chain to upgrade configuration", "err", compat)
|
||||
|
|
@ -201,17 +216,6 @@ func New(stack *node.Node, config *Config) (*Ethereum, error) {
|
|||
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
|
||||
eth.miner.SetExtra(makeExtraData(config.Miner.ExtraData))
|
||||
|
||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), eth, nil}
|
||||
gpoParams := config.GPO
|
||||
if gpoParams.Default == nil {
|
||||
gpoParams.Default = config.Miner.GasPrice
|
||||
}
|
||||
eth.APIBackend.gpo = gasprice.NewOracle(eth.APIBackend, gpoParams)
|
||||
|
||||
// create eth api and set engine
|
||||
ethAPI := ethapi.NewPublicBlockChainAPI(eth.APIBackend)
|
||||
eth.engine = CreateConsensusEngine(stack, chainConfig, config, chainDb, ethAPI)
|
||||
|
||||
eth.dialCandidates, err = eth.setupDiscovery(&stack.Config().P2P)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -232,7 +236,7 @@ func makeExtraData(extra []byte) []byte {
|
|||
// create default extradata
|
||||
extra, _ = rlp.EncodeToBytes([]interface{}{
|
||||
uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch),
|
||||
"geth",
|
||||
"bor",
|
||||
runtime.Version(),
|
||||
runtime.GOOS,
|
||||
})
|
||||
|
|
@ -559,3 +563,12 @@ func (s *Ethereum) Stop() error {
|
|||
s.eventMux.Stop()
|
||||
return nil
|
||||
}
|
||||
|
||||
//
|
||||
// Bor related methods
|
||||
//
|
||||
|
||||
// SetBlockchain set blockchain while testing
|
||||
func (s *Ethereum) SetBlockchain(blockchain *core.BlockChain) {
|
||||
s.blockchain = blockchain
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue