aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorgary rong <garyrong0905@gmail.com>2017-11-24 22:10:27 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-11-24 22:10:27 +0800
commitf14047dae57aa69e4fa08d57e19ee9c0283dfa54 (patch)
treeb1b9523a4ce12e2b3cc472bdcf38df7ddbd4bdcc /eth/backend.go
parentb0056f5bd096adf42a2c28cd76264f230c7cae20 (diff)
downloadgo-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar.gz
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar.bz2
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar.lz
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar.xz
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.tar.zst
go-tangerine-f14047dae57aa69e4fa08d57e19ee9c0283dfa54.zip
cmd, consensus, eth: split ethash related config to it own (#15520)
* cmd, consensus, eth: split ethash related config to it own * eth, consensus: minor polish * eth, consenus, console: compress pow testing config field to single one * consensus, eth: document pow mode
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go20
1 files changed, 13 insertions, 7 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 1cd9e8fff..e7f0f57dd 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -125,7 +125,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
chainConfig: chainConfig,
eventMux: ctx.EventMux,
accountManager: ctx.AccountManager,
- engine: CreateConsensusEngine(ctx, config, chainConfig, chainDb),
+ engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, chainDb),
shutdownChan: make(chan bool),
stopDbUpgrade: stopDbUpgrade,
networkId: config.NetworkId,
@@ -209,25 +209,31 @@ func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Data
}
// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service
-func CreateConsensusEngine(ctx *node.ServiceContext, config *Config, chainConfig *params.ChainConfig, db ethdb.Database) consensus.Engine {
+func CreateConsensusEngine(ctx *node.ServiceContext, config *ethash.Config, chainConfig *params.ChainConfig, db ethdb.Database) consensus.Engine {
// If proof-of-authority is requested, set it up
if chainConfig.Clique != nil {
return clique.New(chainConfig.Clique, db)
}
// Otherwise assume proof-of-work
switch {
- case config.PowFake:
+ case config.PowMode == ethash.ModeFake:
log.Warn("Ethash used in fake mode")
return ethash.NewFaker()
- case config.PowTest:
+ case config.PowMode == ethash.ModeTest:
log.Warn("Ethash used in test mode")
return ethash.NewTester()
- case config.PowShared:
+ case config.PowMode == ethash.ModeShared:
log.Warn("Ethash used in shared mode")
return ethash.NewShared()
default:
- engine := ethash.New(ctx.ResolvePath(config.EthashCacheDir), config.EthashCachesInMem, config.EthashCachesOnDisk,
- config.EthashDatasetDir, config.EthashDatasetsInMem, config.EthashDatasetsOnDisk)
+ engine := ethash.New(ethash.Config{
+ CacheDir: ctx.ResolvePath(config.CacheDir),
+ CachesInMem: config.CachesInMem,
+ CachesOnDisk: config.CachesOnDisk,
+ DatasetDir: config.DatasetDir,
+ DatasetsInMem: config.DatasetsInMem,
+ DatasetsOnDisk: config.DatasetsOnDisk,
+ })
engine.SetThreads(-1) // Disable CPU mining
return engine
}