mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
make the diff adjustments better
This commit is contained in:
parent
5745c9a303
commit
8997f08ecc
2 changed files with 10 additions and 1 deletions
|
|
@ -40,7 +40,14 @@ var (
|
||||||
// given the parent block's time and difficulty.
|
// given the parent block's time and difficulty.
|
||||||
func CalcDifficulty(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
|
func CalcDifficulty(time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
|
||||||
diff := new(big.Int)
|
diff := new(big.Int)
|
||||||
adjust := new(big.Int).Div(parentDiff, params.DifficultyBoundDivisor)
|
adjust := new(big.Int)
|
||||||
|
|
||||||
|
if parentNumber.Cmp(params.HardFork1) < 0 {
|
||||||
|
adjust = new(big.Int).Div(parentDiff, params.DifficultyBoundDivisor)
|
||||||
|
} else {
|
||||||
|
adjust = new(big.Int).Div(parentDiff, params.DifficultyBoundDivisor2)
|
||||||
|
}
|
||||||
|
|
||||||
bigTime := new(big.Int)
|
bigTime := new(big.Int)
|
||||||
bigParentTime := new(big.Int)
|
bigParentTime := new(big.Int)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ var (
|
||||||
TxGas = big.NewInt(21000) // Per transaction. NOTE: Not payable on data of calls between transactions.
|
TxGas = big.NewInt(21000) // Per transaction. NOTE: Not payable on data of calls between transactions.
|
||||||
TxDataZeroGas = big.NewInt(4) // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions.
|
TxDataZeroGas = big.NewInt(4) // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions.
|
||||||
DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations.
|
DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations.
|
||||||
|
DifficultyBoundDivisor2 = big.NewInt(512) // Difficulty should adjust faster.
|
||||||
|
HardFork1 = big.NewInt(23000) // fork at this block number
|
||||||
QuadCoeffDiv = big.NewInt(512) // Divisor for the quadratic particle of the memory cost equation.
|
QuadCoeffDiv = big.NewInt(512) // Divisor for the quadratic particle of the memory cost equation.
|
||||||
GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block.
|
GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block.
|
||||||
DurationLimit = big.NewInt(60) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
|
DurationLimit = big.NewInt(60) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue