mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-13 07:23:46 +00:00
fix: flow in create consensus engine
This commit is contained in:
parent
672a15e339
commit
08509c6882
1 changed files with 5 additions and 27 deletions
|
|
@ -227,38 +227,17 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
|
||||||
noverify := ethConfig.Miner.Noverify
|
noverify := ethConfig.Miner.Noverify
|
||||||
|
|
||||||
// If proof-of-authority is requested, set it up
|
// If proof-of-authority is requested, set it up
|
||||||
var engine consensus.Engine
|
|
||||||
if chainConfig.Clique != nil {
|
if chainConfig.Clique != nil {
|
||||||
engine = clique.New(chainConfig.Clique, db)
|
return clique.New(chainConfig.Clique, db)
|
||||||
} else {
|
|
||||||
switch config.PowMode {
|
|
||||||
case ethash.ModeFake:
|
|
||||||
log.Warn("Ethash used in fake mode")
|
|
||||||
case ethash.ModeTest:
|
|
||||||
log.Warn("Ethash used in test mode")
|
|
||||||
case ethash.ModeShared:
|
|
||||||
log.Warn("Ethash used in shared mode")
|
|
||||||
}
|
|
||||||
engine = ethash.New(ethash.Config{
|
|
||||||
PowMode: config.PowMode,
|
|
||||||
CacheDir: stack.ResolvePath(config.CacheDir),
|
|
||||||
CachesInMem: config.CachesInMem,
|
|
||||||
CachesOnDisk: config.CachesOnDisk,
|
|
||||||
CachesLockMmap: config.CachesLockMmap,
|
|
||||||
DatasetDir: config.DatasetDir,
|
|
||||||
DatasetsInMem: config.DatasetsInMem,
|
|
||||||
DatasetsOnDisk: config.DatasetsOnDisk,
|
|
||||||
DatasetsLockMmap: config.DatasetsLockMmap,
|
|
||||||
NotifyFull: config.NotifyFull,
|
|
||||||
}, notify, noverify)
|
|
||||||
engine.(*ethash.Ethash).SetThreads(-1) // Disable CPU mining
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Matic bor consensus is requested, set it up
|
// If Matic bor consensus is requested, set it up
|
||||||
// In order to pass the ethereum transaction tests, we need to set the burn contract which is in the bor config
|
// In order to pass the ethereum transaction tests, we need to set the burn contract which is in the bor config
|
||||||
// Then, bor != nil will also be enabled for ethash and clique. Only enable Bor for real if there is a validator contract present.
|
// Then, bor != nil will also be enabled for ethash and clique. Only enable Bor for real if there is a validator contract present.
|
||||||
if chainConfig.Bor != nil && chainConfig.Bor.ValidatorContract != "" {
|
if chainConfig.Bor != nil && chainConfig.Bor.ValidatorContract != "" {
|
||||||
return bor.New(chainConfig, db, blockchainAPI, ethConfig.HeimdallURL, ethConfig.WithoutHeimdall)
|
return bor.New(chainConfig, db, blockchainAPI, ethConfig.HeimdallURL, ethConfig.WithoutHeimdall)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise assume proof-of-work
|
// Otherwise assume proof-of-work
|
||||||
switch config.PowMode {
|
switch config.PowMode {
|
||||||
case ethash.ModeFake:
|
case ethash.ModeFake:
|
||||||
|
|
@ -268,7 +247,7 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
|
||||||
case ethash.ModeShared:
|
case ethash.ModeShared:
|
||||||
log.Warn("Ethash used in shared mode")
|
log.Warn("Ethash used in shared mode")
|
||||||
}
|
}
|
||||||
engine = ethash.New(ethash.Config{
|
engine := ethash.New(ethash.Config{
|
||||||
PowMode: config.PowMode,
|
PowMode: config.PowMode,
|
||||||
CacheDir: stack.ResolvePath(config.CacheDir),
|
CacheDir: stack.ResolvePath(config.CacheDir),
|
||||||
CachesInMem: config.CachesInMem,
|
CachesInMem: config.CachesInMem,
|
||||||
|
|
@ -280,7 +259,6 @@ func CreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, et
|
||||||
DatasetsLockMmap: config.DatasetsLockMmap,
|
DatasetsLockMmap: config.DatasetsLockMmap,
|
||||||
NotifyFull: config.NotifyFull,
|
NotifyFull: config.NotifyFull,
|
||||||
}, notify, noverify)
|
}, notify, noverify)
|
||||||
// TODO - Check this
|
engine.SetThreads(-1) // Disable CPU mining
|
||||||
// engine.SetThreads(-1) // Disable CPU mining
|
|
||||||
return engine
|
return engine
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue