mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
eth: refactored New function
This commit is contained in:
parent
ab7a820512
commit
bf9f447c42
1 changed files with 23 additions and 24 deletions
|
|
@ -141,7 +141,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
}
|
}
|
||||||
log.Info("Allocated trie memory caches", "clean", common.StorageSize(config.TrieCleanCache)*1024*1024, "dirty", common.StorageSize(config.TrieDirtyCache)*1024*1024)
|
log.Info("Allocated trie memory caches", "clean", common.StorageSize(config.TrieCleanCache)*1024*1024, "dirty", common.StorageSize(config.TrieDirtyCache)*1024*1024)
|
||||||
|
|
||||||
// Assemble the Ethereum object
|
|
||||||
chainDb, err := stack.OpenDatabaseWithFreezer("chaindata", config.DatabaseCache, config.DatabaseHandles, config.DatabaseFreezer, "ethereum/db/chaindata/", false, false, false)
|
chainDb, err := stack.OpenDatabaseWithFreezer("chaindata", config.DatabaseCache, config.DatabaseHandles, config.DatabaseFreezer, "ethereum/db/chaindata/", false, false, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -157,7 +156,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// START: Bor changes
|
// Here we determine active ChainConfig.
|
||||||
|
chainConfig, _, err := core.LoadChainConfig(chainDb, config.Genesis)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assemble the Ethereum object.
|
||||||
eth := &Ethereum{
|
eth := &Ethereum{
|
||||||
config: config,
|
config: config,
|
||||||
chainDb: chainDb,
|
chainDb: chainDb,
|
||||||
|
|
@ -173,6 +178,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
closeCh: make(chan struct{}),
|
closeCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// START: Bor changes
|
||||||
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
|
||||||
if eth.APIBackend.allowUnprotectedTxs {
|
if eth.APIBackend.allowUnprotectedTxs {
|
||||||
log.Info("------Unprotected transactions allowed-------")
|
log.Info("------Unprotected transactions allowed-------")
|
||||||
|
|
@ -181,32 +187,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
|
|
||||||
gpoParams := config.GPO
|
gpoParams := config.GPO
|
||||||
|
|
||||||
// Override the chain config with provided settings.
|
|
||||||
var overrides core.ChainOverrides
|
|
||||||
if config.OverridePrague != nil {
|
|
||||||
overrides.OverridePrague = config.OverridePrague
|
|
||||||
}
|
|
||||||
if config.OverrideVerkle != nil {
|
|
||||||
overrides.OverrideVerkle = config.OverrideVerkle
|
|
||||||
}
|
|
||||||
|
|
||||||
// chainConfig, genesisHash, compatErr, err := core.SetupGenesisBlockWithOverride(chainDb, triedb.NewDatabase(chainDb, triedb.HashDefaults), config.Genesis, &overrides)
|
|
||||||
// if err != nil {
|
|
||||||
// return nil, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// rawdb.WriteChainConfig(chainDb, genesisHash, chainConfig)
|
|
||||||
|
|
||||||
blockChainAPI := ethapi.NewBlockChainAPI(eth.APIBackend)
|
blockChainAPI := ethapi.NewBlockChainAPI(eth.APIBackend)
|
||||||
engine, err := ethconfig.CreateConsensusEngine(config.Genesis.Config, config, chainDb, blockChainAPI)
|
engine, err := ethconfig.CreateConsensusEngine(chainConfig, config, chainDb, blockChainAPI)
|
||||||
eth.engine = engine
|
eth.engine = engine
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// if compatErr != nil {
|
|
||||||
// return nil, compatErr
|
|
||||||
// }
|
|
||||||
// END: Bor changes
|
// END: Bor changes
|
||||||
|
|
||||||
bcVersion := rawdb.ReadDatabaseVersion(chainDb)
|
bcVersion := rawdb.ReadDatabaseVersion(chainDb)
|
||||||
|
|
@ -258,6 +244,15 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
|
|
||||||
checker := whitelist.NewService(chainDb)
|
checker := whitelist.NewService(chainDb)
|
||||||
|
|
||||||
|
// Override the chain config with provided settings.
|
||||||
|
var overrides core.ChainOverrides
|
||||||
|
if config.OverridePrague != nil {
|
||||||
|
overrides.OverridePrague = config.OverridePrague
|
||||||
|
}
|
||||||
|
if config.OverrideVerkle != nil {
|
||||||
|
overrides.OverrideVerkle = config.OverrideVerkle
|
||||||
|
}
|
||||||
|
|
||||||
// check if Parallel EVM is enabled
|
// check if Parallel EVM is enabled
|
||||||
// if enabled, use parallel state processor
|
// if enabled, use parallel state processor
|
||||||
if config.ParallelEVM.Enable {
|
if config.ParallelEVM.Enable {
|
||||||
|
|
@ -272,7 +267,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = eth.engine.VerifyHeader(eth.blockchain, eth.blockchain.CurrentHeader()) // TODO think on it
|
// bor: this is nor present in geth
|
||||||
|
/*
|
||||||
|
_ = eth.engine.VerifyHeader(eth.blockchain, eth.blockchain.CurrentHeader()) // TODO think on it
|
||||||
|
*/
|
||||||
|
|
||||||
// BOR changes
|
// BOR changes
|
||||||
eth.APIBackend.gpo.ProcessCache()
|
eth.APIBackend.gpo.ProcessCache()
|
||||||
|
|
@ -325,6 +323,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
||||||
// Permit the downloader to use the trie cache allowance during fast sync
|
// Permit the downloader to use the trie cache allowance during fast sync
|
||||||
cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit + cacheConfig.SnapshotLimit
|
cacheLimit := cacheConfig.TrieCleanLimit + cacheConfig.TrieDirtyLimit + cacheConfig.SnapshotLimit
|
||||||
if eth.handler, err = newHandler(&handlerConfig{
|
if eth.handler, err = newHandler(&handlerConfig{
|
||||||
|
NodeID: eth.p2pServer.Self().ID(),
|
||||||
Database: chainDb,
|
Database: chainDb,
|
||||||
Chain: eth.blockchain,
|
Chain: eth.blockchain,
|
||||||
TxPool: eth.txPool,
|
TxPool: eth.txPool,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue