New gas prices model

This commit is contained in:
obscuren
2015-03-02 16:32:02 +01:00
parent 73c52d1677
commit b383ff0b96
5 changed files with 193 additions and 120 deletions

View File

@ -28,11 +28,13 @@ type StateQuery interface {
func CalcDifficulty(block, parent *types.Block) *big.Int {
diff := new(big.Int)
adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
if block.Time() >= parent.Time()+8 {
diff.Sub(parent.Difficulty(), adjust)
} else {
//adjust := new(big.Int).Rsh(parent.Difficulty(), 10)
//if block.Time() >= parent.Time()+8 {
adjust := new(big.Int).Div(parent.Difficulty(), big.NewInt(2048))
if (block.Time() - parent.Time()) < 8 {
diff.Add(parent.Difficulty(), adjust)
} else {
diff.Sub(parent.Difficulty(), adjust)
}
return diff