diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-10 01:06:16 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-10 01:06:16 +0800 |
commit | 27290e12772f4a354cfdc6383222597f66cefa21 (patch) | |
tree | adaffc9e9ce6c06a4219dd6a8355244360390d9c /ethchain/block.go | |
parent | c51db4c940a5ea679aee580a673a4ccdd2421b9a (diff) | |
download | dexon-27290e12772f4a354cfdc6383222597f66cefa21.tar.gz dexon-27290e12772f4a354cfdc6383222597f66cefa21.tar.zst dexon-27290e12772f4a354cfdc6383222597f66cefa21.zip |
Fixed gas limit calculation
Diffstat (limited to 'ethchain/block.go')
-rw-r--r-- | ethchain/block.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ethchain/block.go b/ethchain/block.go index 321af6183..5b06fd58d 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -130,8 +130,10 @@ func (block *Block) CalcGasLimit(parent *Block) *big.Int { return ethutil.BigPow(10, 6) } - previous := new(big.Int).Mul(big.NewInt(1023), parent.GasLimit) - current := new(big.Rat).Mul(new(big.Rat).SetInt(block.GasUsed), big.NewRat(6, 5)) + // ((1024-1) * parent.gasLimit + (gasUsed * 6 / 5)) / 1024 + + previous := new(big.Int).Mul(big.NewInt(1024-1), parent.GasLimit) + current := new(big.Rat).Mul(new(big.Rat).SetInt(parent.GasUsed), big.NewRat(6, 5)) curInt := new(big.Int).Div(current.Num(), current.Denom()) result := new(big.Int).Add(previous, curInt) |