--ethash.difficulty

This commit is contained in:
Andrew Roldugin 2018-08-21 20:15:44 +03:00
parent 245b0ab754
commit a2ce52efbf
7 changed files with 12 additions and 2 deletions

View file

@ -72,6 +72,7 @@ var (
utils.EthashDatasetDirFlag, utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag, utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag, utils.EthashDatasetsOnDiskFlag,
utils.EthashDifficultyFlag,
utils.TxPoolNoLocalsFlag, utils.TxPoolNoLocalsFlag,
utils.TxPoolJournalFlag, utils.TxPoolJournalFlag,
utils.TxPoolRejournalFlag, utils.TxPoolRejournalFlag,

View file

@ -99,6 +99,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.EthashDatasetDirFlag, utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag, utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag, utils.EthashDatasetsOnDiskFlag,
utils.EthashDifficultyFlag,
}, },
}, },
//{ //{

View file

@ -241,6 +241,11 @@ var (
Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)", Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)",
Value: ess.DefaultConfig.Ethash.DatasetsOnDisk, Value: ess.DefaultConfig.Ethash.DatasetsOnDisk,
} }
EthashDifficultyFlag = BigFlag{
Name: "ethash.difficulty",
Usage: "Difficulty of ethash",
Value: ess.DefaultConfig.Ethash.Difficulty,
}
// Transaction pool settings // Transaction pool settings
TxPoolNoLocalsFlag = cli.BoolFlag{ TxPoolNoLocalsFlag = cli.BoolFlag{
Name: "txpool.nolocals", Name: "txpool.nolocals",

View file

@ -288,7 +288,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
// the difficulty that a new block should have when created at time // the difficulty that a new block should have when created at time
// given the parent block's time and difficulty. // given the parent block's time and difficulty.
func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int { func (ethash *Ethash) CalcDifficulty(chain consensus.ChainReader, time uint64, parent *types.Header) *big.Int {
return CalcDifficulty(chain.Config(), time, parent) return ethash.config.Difficulty
} }
// CalcDifficulty is the difficulty adjustment algorithm. It returns // CalcDifficulty is the difficulty adjustment algorithm. It returns

View file

@ -47,7 +47,7 @@ var (
maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0)) maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
// sharedEthash is a full instance that can be shared between multiple users. // sharedEthash is a full instance that can be shared between multiple users.
sharedEthash = New(Config{"", 3, 0, "", 1, 0, ModeNormal}) sharedEthash = New(Config{"", 3, 0, "", 1, 0, ModeNormal, big.NewInt(1)})
// algorithmRevision is the data structure version used for file naming. // algorithmRevision is the data structure version used for file naming.
algorithmRevision = 23 algorithmRevision = 23
@ -387,6 +387,7 @@ type Config struct {
DatasetsInMem int DatasetsInMem int
DatasetsOnDisk int DatasetsOnDisk int
PowMode Mode PowMode Mode
Difficulty *big.Int
} }
// Ethash is a consensus engine based on proof-of-work implementing the ethash // Ethash is a consensus engine based on proof-of-work implementing the ethash

View file

@ -117,6 +117,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Essentia, error) {
return nil, genesisErr return nil, genesisErr
} }
log.Info("Initialised chain configuration", "config", chainConfig) log.Info("Initialised chain configuration", "config", chainConfig)
log.Info("Ethash", "difficulty", config.Ethash.Difficulty)
ess := &Essentia{ ess := &Essentia{
config: config, config: config,

View file

@ -42,6 +42,7 @@ var DefaultConfig = Config{
CachesOnDisk: 3, CachesOnDisk: 3,
DatasetsInMem: 1, DatasetsInMem: 1,
DatasetsOnDisk: 2, DatasetsOnDisk: 2,
Difficulty: big.NewInt(1),
}, },
NetworkId: 1, NetworkId: 1,
LightPeers: 100, LightPeers: 100,