mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
Test of EXPDiff
This commit is contained in:
parent
aed7ebaf90
commit
92b83a260b
1 changed files with 23 additions and 3 deletions
|
|
@ -298,11 +298,11 @@ func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Heade
|
||||||
next := new(big.Int).Add(parent.Number, big1)
|
next := new(big.Int).Add(parent.Number, big1)
|
||||||
switch {
|
switch {
|
||||||
case config.IsByzantium(next):
|
case config.IsByzantium(next):
|
||||||
return calcDifficultyByzantium(time, parent)
|
return calcDifficultyEGEM(time, parent)
|
||||||
case config.IsHomestead(next):
|
case config.IsHomestead(next):
|
||||||
return calcDifficultyHomestead(time, parent)
|
return calcDifficultyEGEM(time, parent)
|
||||||
default:
|
default:
|
||||||
return calcDifficultyFrontier(time, parent)
|
return calcDifficultyEGEM(time, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,6 +458,26 @@ func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int {
|
||||||
return diff
|
return diff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int {
|
||||||
|
diff := new(big.Int)
|
||||||
|
adjust := new(big.Int).Div(parent.Difficulty, big10)
|
||||||
|
bigTime := new(big.Int)
|
||||||
|
bigParentTime := new(big.Int)
|
||||||
|
|
||||||
|
bigTime.SetUint64(time)
|
||||||
|
bigParentTime.Set(parent.Time)
|
||||||
|
|
||||||
|
if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 {
|
||||||
|
diff.Add(parent.Difficulty, adjust)
|
||||||
|
} else {
|
||||||
|
diff.Sub(parent.Difficulty, adjust)
|
||||||
|
}
|
||||||
|
if diff.Cmp(params.MinimumDifficulty) < 0 {
|
||||||
|
diff.Set(params.MinimumDifficulty)
|
||||||
|
}
|
||||||
|
return diff
|
||||||
|
}
|
||||||
|
|
||||||
// VerifySeal implements consensus.Engine, checking whether the given block satisfies
|
// VerifySeal implements consensus.Engine, checking whether the given block satisfies
|
||||||
// the PoW difficulty requirements.
|
// the PoW difficulty requirements.
|
||||||
func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Header) error {
|
func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Header) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue